Re: [fpc-pascal] Ignoring function results

2017-05-20 Thread Mark Morgan Lloyd

On 20/05/17 12:30, Bart wrote:

On 5/20/17, Mark Morgan Lloyd  wrote:

According to the Programmer's Guide 1.3.41, {$EXTENDEDSYNTAX OFF} has> the 
effect of permitting the result of a function to be ignored.

Isn't that just the other way around?
"Extended syntax allows you to drop the result of a function. Thismeans that you can 
use a function call as if it were a procedure.By default this feature is on. You can 
switch it off using the {$X-}or {$EXTENDEDSYNTAX OFF}directive."


Just a mo, let me have another shot at that in case I was doing 
something stupid...


it's definitely got to be on for optional parameters to be accepted, and 
that appears to be the default state if {$mode objfpc}{$H+} is at the 
top of the unit.


The curious thing is that in the cold light of day I can't get 
$EXTENDEDSYNTAX to have any effect on the function result. I'll admit 
what I'm doing:


operator <= (var a: TDateTimeArray; const s: TDateTime): boolean;

begin
  result := Length(a) > 0;
  SetLength(a, Length(a) + 1);
  a[High(a)] := s
end { <= } ;

operator + (const a: TDateTimeArray; const s: TDateTime): TDateTimeArray;

var b: boolean;

begin
  result := a;
  if Length(result) = 0 then
{ b := } result <= s
  else
result[High(result)] += s
end { + } ;

If I uncomment the boolean assignment it works. Where I appeared to be 
last night was that setting $EXTENDEDSYNTAX OFF had the above working, 
but I'm now having trouble duplicating it. And I hadn't touched a drop :-)


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Ignoring function results

2017-05-20 Thread Bart
On 5/20/17, Mark Morgan Lloyd  wrote:

> According to the Programmer's Guide 1.3.41, {$EXTENDEDSYNTAX OFF} has
> the effect of permitting the result of a function to be ignored.

Isn't that just the other way around?

"Extended syntax allows you to drop the result of a function. This
means that you can use a function call as if it were a procedure.
By default this feature is on. You can switch it off using the {$X-}
or {$EXTENDEDSYNTAX OFF}directive."

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

[fpc-pascal] Ignoring function results

2017-05-19 Thread Mark Morgan Lloyd
According to the Programmer's Guide 1.3.41, {$EXTENDEDSYNTAX OFF} has 
the effect of permitting the result of a function to be ignored.


However it also appears to (at least) prohibit functions/procedures with 
optional parameters: can these be controlled separately?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal