Re: [fpc-pascal] SetLength warnings - request
On 10/01/19 20:23, Martok wrote: Something I just found out, while changing some old code: why does that not work? var u: UnicodeString = nil; // Incompatible types: got "Pointer" expected "UnicodeString" a: AnsiString = nil; // Illegal Expression c: TCharArray = ''; // Syntax error, "(" expected but "const string" found Simply using '' as an initializer for Strings and nil for arrays solves it, so it's no big deal. I'm just curious why Strings do not have the niln typeconv I'm fairly sure this was based on what Delphi allows and doesn't. Maybe it's because strings already had a primitive to initialise them to nil (and empty string) and arrays didn't (since array constants in code blocks did not exist at that time). and why the TCharArray can't be initialized (but assigned at runtime) with ''. '' is parsed as a string constant, which means internally it becomes an array of char. The compiler does not support compile-time conversions of (constant or not) regular arrays to dynamic arrays. And why only the UnicodeString message actually relates what is wrong... ? The CharArray error is also correct: array constants start with '('. I don't know why the ansistring error is less informative than the unicodestring one. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SetLength warnings - request
Am 29.12.2018 um 22:35 schrieb Jonas Maebe: > You don't need to typecast dynamic arrays to pointer to initialise them > with nil. Simply "arr:=nil;" works. Ideally, the compiler would remove > this extra initialisation if you add it before it got a different value, > but it does not yet do that. Something I just found out, while changing some old code: why does that not work? var u: UnicodeString = nil; // Incompatible types: got "Pointer" expected "UnicodeString" a: AnsiString = nil; // Illegal Expression c: TCharArray = ''; // Syntax error, "(" expected but "const string" found Simply using '' as an initializer for Strings and nil for arrays solves it, so it's no big deal. I'm just curious why Strings do not have the niln typeconv and why the TCharArray can't be initialized (but assigned at runtime) with ''. And why only the UnicodeString message actually relates what is wrong... ? -- Regards, Martok ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Multi-scope helpers draft
On Sat, 24 Nov 2018 11:20:05 +0700 Ryan Joseph wrote: > I’d like to propose this mode switch ($modeswitch multiscopehelpers) > to allow multiple helpers per scope. Can you explain the order/precedence of multiple helpers? Btw, why is the modeswitch called multiscopehelpers instead of multihelpers or allhelpers? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal