-
Content Count
3324 -
Joined
-
Last visited
-
Days Won
110
Everything posted by Lars Fosdal
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Wow, I didn't notice that! And it is not related to declaration order, nor ordinal value. That is a bit disturbing.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
The inconsistent behavior between the two variations of enumerated types is another pitfall, I guess.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Or pitfall 😛- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Off-topic - I actually do reverse for in loops with a custom enumerator which starts on top and decrements instead.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
@Uwe Raabe Are you saying that for ix := Low(Array) to High(Array) do begin v := Array[ix]; is predictable - while for v in Array is not predictable ?- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
I wonder how it behaves if I have a set enumerated type with hard coded ordinal values? Edit Change the declaration to TEnum = (plough = 5, foo = 9, bar = 14, wtf = 1); Now the set behaves just like the array.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Except it is rare to see a TList or any other object structure "hardcoded" in plain sight, while arrays of simple types are not hard to read nor uncommon.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
For a list or any other object enumeration interface, I'd agree - but for an open array or a TArray?- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Delphi pitfalls: Enumerated types and for loops
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
It is pretty quick to miss that "detail". They look the same, so unless you really pay attention to the type element type - there is little to tell you that you are looking at a set and not a list.- 39 replies
-
- pitfall
- enumerated type
-
(and 1 more)
Tagged with:
-
Pitfalls of Anonymous methods and capture
Lars Fosdal posted a topic in RTL and Delphi Object Pascal
Code that looks correct, and appear to compile alright, but which doesn't execute well. Can you spot the error? See my blog post for a link to a SCCE. var Handler: THandlerClass; hType: THandlers; begin Broker.Clear; for hType in [foo, bar] do begin case hType of foo: Handler := TFoo.Create; bar: Handler := TBar.Create; end; Broker.AddHandler(Handler.OnHandle); end; end; https://larsfosdal.blog/2019/02/08/delphi-pitfalls-of-anonymous-methods-and-capture/ -
Pitfalls of Anonymous methods and capture
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Close, its a Self-Contained Compilable Example, sometimes also called a SSCCE, i.e. a Short SCCE. I'll rewrite the article for better readability. -
How to pass an unknown record to a function as argument
Lars Fosdal replied to John Kouraklis's topic in RTL and Delphi Object Pascal
Is this related to databases? -
Pitfalls of Anonymous methods and capture
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
There is one, but you "wasn't about to download some project from a file sharing site" (i.e. a zip file with source code from Google Drive) -
Pitfalls of Anonymous methods and capture
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
@David Heffernan If you added me to your Ignore list here on DP, I would be totally fine with that. -
Pitfalls of Anonymous methods and capture
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Which is why my post specifically pointed out that there is a link to the SCCE in the blog post? -
Pitfalls of Anonymous methods and capture
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Yes, the examples leak. I didn't want to clutter it up with too much housekeeping code. Thank you, Uwe, for enlightening me on variable vs value capture. IMO, the compiler could need a hint or warning if a variable capture happens in a loop, because it is really easy to overlook. I use a number of variations on this to do dependency injection. It really helps with avoiding pulling too much project specific code into general code and keep the libraries isolated from each other. This code in particular is part of a web server that (now correctly) supports a configurable collection of JsonRPC protocol handlers. The web server knows nothing about Json, and the protocol handlers knows almost nothing about http. -
Anybody else see the same?
-
10.2 Tokyo unable to report issues from within the IDE
Lars Fosdal replied to Lars Fosdal's topic in General Help
What do we know about the state of 10.3 Rio in this context? -
Does anyone know if there are existing libs out there that can extract this across all FMX platforms? - Current user - Device name
-
Cross-platform discovery of device name and user name?
Lars Fosdal replied to Lars Fosdal's topic in Cross-platform
https://developer.android.com/training/id-auth/identify Would this be usable to get some sort of username / identity? Perhaps there is something similar on iOS as well? -
Request for advice: FireMonkey and Frames
Lars Fosdal replied to Lars Fosdal's topic in Cross-platform
So basically just like for VCL. Nice. -
Request for advice: FireMonkey and Frames
Lars Fosdal replied to Lars Fosdal's topic in Cross-platform
@Rollo62 Can you exemplify how you "load via runtime into TRectangles" ? In my current app, I want to instantiate the frame onto a TTabItem. -
Opinions solicited: Parallel processing to delete 40+Gig file structure?
Lars Fosdal replied to KeithLatham's topic in RTL and Delphi Object Pascal
SSD disks are usually connected via SATA (Serial ATA) or PCIe using the NVMe protocol. The first does not do parallel operations, while the second does. However, the speed benefit of the latter is when writing large amounts of data in parallel to individual areas. When deleting files, the OS is rewriting minor amounts of data in a shared area that needs to be integrity managed i.e. shared access locking, so I would suspect that there is no gain to parallelizing deletion of files. -
E2158 System unit out of date or corrupted: missing '@Clr' - how to cure?
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Doh! Never mind! I had commented out one of two overloaded methods in the interface section. There was another "fatal" compilation error further up in the compiler output list. Basically, it was just a weird IDE/compiler artifact due to invalid code. -
I have a new stored proc that takes a varchar(max) argument for logging - and I occasionally run into this problem when the argument is very long. It then raises the following exception EFDException [FireDAC][Phys][ODBC]-345. Data too large for variable [#9]. Max len = [8000], actual len = [24448] Hint: set the TFDParam.Size to a greater value Note that I have a couple of varchar(5000) arguments in the same method that does not complain, so I assume that the default length for strings is 8000 chars. What is the best practice for dealing with this situation? My wrapper code for the stored proc does not really know anything about the potential sizes of these strings as it passes the values as variants. Is it acceptable to always measure the length of the string and dynamically increase TFDParam.size? I have a case already that deals with XML logging to an XML field. vtUnicodeString: begin p.DataType := ftString; s := String(ConstParams[ix].VUnicodeString); len := Length(s) * SizeOf(Char); if Len > p.Size // Autosize then begin p.DataType := ftWideMemo; p.Size := Len + 2; end; p.Value := s; end; But - what happens if the actual field is not type , but [varchar(max)] ? Can I do the above for long string fields? What is the recommended action for handling changes to TFDParam.size for long varchar arguments?