Re: [fpc-pascal] Question on TFPGMap

2023-01-01 Thread Sven Barth via fpc-pascal
ppadilcdx--- via fpc-pascal  schrieb am
Mo., 2. Jan. 2023, 02:29:

> Sorry copy and paste error. d = decode. Corrected below.  But I think I
> see what you mean.  Just assigning a type to decode doesn't initialize
> it. But the compiler is happy with it, i.e. it doesn't call as illegal
> the statement "decode.create".
>

That is because constructors can also be called as regular methods. But the
instance will only be created if you call a constructor using the type.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Question on TFPGMap

2023-01-01 Thread Hairy Pixels via fpc-pascal


> On Jan 2, 2023, at 8:29 AM, ppadilcdx--- via fpc-pascal 
>  wrote:
> 
> Sorry copy and paste error. d = decode. Corrected below.  But I think I see 
> what you mean.  Just assigning a type to decode doesn't initialize it. But 
> the compiler is happy with it, i.e. it doesn't call as illegal the statement 
> "decode.create".

Yeah you certainly need to assigned it to the variable or obviously that 
variable will be uninitialized and thus  “d.add” will be an error.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Question on TFPGMap

2023-01-01 Thread ppadilcdx--- via fpc-pascal
Sorry copy and paste error. d = decode. Corrected below.  But I think I 
see what you mean.  Just assigning a type to decode doesn't initialize 
it. But the compiler is happy with it, i.e. it doesn't call as illegal 
the statement "decode.create".


On 1/1/23 5:21 PM, Hairy Pixels via fpc-pascal wrote:



On Jan 2, 2023, at 6:57 AM, ppadilcdx--- via fpc-pascal 
 wrote:

program ex;

uses fgl;

var decode: specialize TFPGMap;

begin
decode.create;
decode.add('X', 1);

end.

This doesn’t make sense. It should be

d := specialize TFPGMap.Create;

Right? What is “decode” and why aren’t you assigning it to anything?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Question on TFPGMap

2023-01-01 Thread Hairy Pixels via fpc-pascal


> On Jan 2, 2023, at 6:57 AM, ppadilcdx--- via fpc-pascal 
>  wrote:
> 
> program ex;
> 
> uses fgl;
> 
> var d: specialize TFPGMap;
> 
> begin
>decode.create;
>decode.add('X', 1);
> 
> end.

This doesn’t make sense. It should be 

d := specialize TFPGMap.Create;

Right? What is “decode” and why aren’t you assigning it to anything?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Question on TFPGMap

2023-01-01 Thread ppadilcdx--- via fpc-pascal
I have a simple example that gives an access violation on the latest 
macos (fpc mode, i.e. no mode switch). What am I missing? Thanks in advance:


program ex;

uses fgl;

var d: specialize TFPGMap;

begin
   decode.create;
   decode.add('X', 1);

end.


An unhandled exception occurred at $0001023917DE:
EAccessViolation: Access violation
  $0001023917DE


Regards

Pete

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal