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

Reply via email to