

Dave Novo
Members-
Content Count
155 -
Joined
-
Last visited
-
Days Won
1
Dave Novo last won the day on March 12 2021
Dave Novo had the most liked content!
Community Reputation
54 ExcellentRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
How do I "Import" Libraries using Python4Delphi?
Dave Novo replied to JohnLM's topic in Python4Delphi
Hi John. Package management on python is something that you need to learn and understand before using Python. If you just install packages willy nilly you will essentially have a non-functional python environment after a while. There are many tools available to help you not shoot yourself in the foot. Out of the box python supports virtual environments. There are package management tools like Conda, Poetry and others. It takes a bit to wrap your mind around it, but just like in Delphi if you install packages where different packages require different versions of other packages you will get yourself into big trouble. Its just that in python you use many more packages (aka 3rd party libraries in Delphi) and the odds that some conflict are much higher simply since there are more of them. -
Evidently, there are issues with cycles. I do admit that our huge 3M LOC application has tons of cycles (where we have stuff in the implementation uses clause that would cause circular references if it was put in the interface). We are working on removing these because evidently they slow down the compiler as well. Over the last 20 years we were not aware there was any downside in having cycles and took no effort to refactor things to prevent them. Now we are far more careful. Evidently, LSP (even Delphi 12.3) does not like these and simply dies on our application. However, that does not explain that even in my relatively simple apps it is still unreliable.
-
Unfortunately, we are not. The company has too many hoops to jump through to get anything out as open source. Plus we used a lot of our base classes and libraries to speed up the coding, so would have to disentangle that.
-
I agree with you. The LSP simply is unusable on our project and we were forced to write our own IDE plugin and utilize DelphiAST to write our own code insight and code completion. Even in much simply projects I am writing (<10 units, a few hundred lines of code) the code completion, ctrl+click to jump to an identifier, does not work well.
-
New to Delphi and to the forum - with questions
Dave Novo replied to Paul Dardeau's topic in General Help
Welcome to the Delphi world. There are lots of tools available for many of the questions your asked. Have a look at the subforum on this site and search for various tools and you will see many examples. Most of the tools have been around for a long time, and are very feature complete and differ by subtleties of usage etc. Delphi Third-Party - Delphi-PRAXiS [en] -for the diagrams, I know both TMS Software and Developer Express have flowcharting tools you can leverage. There are other lesser known ones that are available. Just google "delphi flowchart component" -Similar with Help tools. We used Help and Manual and liked it, but there are many other tools equally as valid. These do not even have to be delphi specific. -Please describe what "font oddities" you are seeing in more details. -Without knowing in more detail what you want, recommending a database is just throwing darts against the wall. All have their pros and cons. -
CreateObservableList example in Spring4D
Dave Novo replied to Dave Novo's topic in Delphi Third-Party
ok, perfect, I got that working. thanks! -
Is there an example anywhere of properly hooking up events to a newly created Observable list in order to be notified if items are added/removed to from the list
-
thanks. I did not realize I had an older version. Just updated....
-
By the way, I tried the code, based on @Stefan Glienke example above var foo:=TCollections.CreateList<string>; var indexedColl := TEnumerable.Select<string, Tuple<Integer,string>>(foo, function(const item: string ;const index: Integer): Tuple<Integer,string> begin Result := Tuple<integer,string>.Create(index, item); end); and it does not compile. I think the problem is that TEnumerable.Select expects a TFunc<T,TResult> The following seems to be okay var foo:=TCollections.CreateList<string>; var idx:=0; var indexedColl := TEnumerable.Select<string, Tuple<Integer,string>>(foo, function(item: string): Tuple<Integer,string> begin Result := Tuple<integer,string>.Create(idx, item); inc(idx); end);
-
I guess I could wrap the above code into something like TEnumerateHelper<T>=class function CreateIndexEnumerator(list:IList<T>):<result is whatever the type of the .Select statement is> also, define a type TIndexedEnumItem<T>=Tuple<Integer,T> and consolidate that all to make somewhat simpler code to use on a day to day basis. I think different logic is needed though if the .Where predicate has an integer enumerator passed in.
-
Hi Stefan, Firstly, I would like to say I think the Spring4D library is amazing, and you have done an amazing service for the Delphi community. Please take anything I write merely as a suggestion, not criticism in any way!!!!!! There seems to be little you cannot do in Spring4D if you are clever. I have been coding in Delphi for decades and recently had occasion to start programming a bit in Python. What I am amazed by is how little code I have to type in Python for common things. Of course, there are pros and cons to other aspects of Python (speed etc - that can be dealt with in a variety of other ways) but for the point I am making here it is just about code simplicity and clarity. I love IShared<T> because it removes hundreds of lines of boilerplate try..finally blocks that on one hand are simple, but the other clutter up the code with useless crap that distracts you from what you are trying to do. The python syntax of new_list = [expression for item in iterable if condition] where new_list is in and of itself an enumerable object that can be plugged into other lists makes the code so simple and clear. Comparing the code var indexedColl := TEnumerable.Select<TMyClass, Tuple<Integer,TMyClass>> (myColl, function(const item: TMyClass; const index: Integer): Tuple<Integer,TMyClass> begin Result := Tuple<integer,TMyClass>.Create(index, item); end) .Where( function(const tuple: Tuple<Integer,TMyClass>): Boolean begin Result := Odd(tuple.Value1); end); to the Python Version indexedColl = [y for x,y in enumerate(myColl) if x%2 != 0] Explanation for non-python people. x is the index, y is the element in myColl at that index. the if statement at the end filters for odd numbers. Of note, indexedColl can be passed as the enumerator directly into anything that accepts an enumerator. I 100% understand that of course Delphi syntax cannot be as simple as Python we have to be specify the types in the generic specialization somehow, but any way that can be moved towards a more simplistic syntax (at least for common use cases) would be helpful. Working with Python has been a real eye opener in the fact that you don't have to break your brain with generics to do everything. (you do have to break your brain in other ways, if people don't use type annotations for example and you spend 1 hour figuring out what type a method is expecting - but that is a different story). Even knowing what you are trying to do in the example above, I would really have to study the code diligently to understand exactly how all the pieces fit together to make it work.
-
Hi Stefan, Sorry, I did not notice the .Where gets an index. But .Where does not seem to satisfy the first requirement. I guess I would have to create my own enumerator and capture it in the .Where method.
-
As a follow up, another key nice addition would be able to do something like this for var curItem in myColl.EnumerateWithIndices([1,5,7,9]) which would return the "indexed enumerator record" for only indexes 1,5,7,9 For this example, you should be able to pass in any IEnumerator/IEnumerable<integer> or something like for var curItem in myColl.EnumerateWithIndices( function (zIdx:integer):Boolean begin result:=IsOdd(zIdx) end ); which would return an "indexed enumerator record" for only odd numbered indexes I will see if I can get a working example over the holidays....
-
How to access/modify underlying records of IList<T>
Dave Novo replied to Dave Novo's topic in Delphi Third-Party
It would be cool if the enumerator supported pointer access to the underlying element. Something like for var curPtr in List.Pointers<PRecord> do begin curPtr.SomeValue:=1; end In the case above, the Pointers record would return a pointer to the underlying item, cast to the pointer type passed in as T. This can be useful for records (and maybe other) to deal with a pointer to the underlying items -
Hello, If I make a list<T> where T is a record, what is the best way to get access to the actual records in the list to make modifications to them? If I was using the built in TList<T> I would use the .List<T>, but Spring4D.IList<T> does not have a property to access the raw list. Is there another way to get access to the actual record instance in the list in order to modify it. calling .Items makes a copy of the underlying record it seems and if I try to enumerate through the list using the enumerator and set a property on the variable in the enumerator I get an error that I cannot set a control loop variable.