Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Schneider
Sven:

> > https://alum.mit.edu/www/toms/ftp/shell.p

> 
> I've now looked at your example code a bit more. Using 3.0.0 (or in my
> case 3.1.1) it compiles if you pass -Miso as parameter. Getting it to
> run confuses me a bit however considering that I've never worked with
> ISO style input/output files. ;) Please note that support for such
> files is new (introduced with 3.0.0) and thus might be buggy. If you
> find any problems with them it would be nice if you report them. :)

-Miso prevented the objection to the goto.  So that's the simplest
thing to do.

Thanks!

Now on to the next problem ...

Tom

  Thomas D. Schneider, Ph.D.
  Senior Investigator
  National Institutes of Health
  National Cancer Institute
  Center for Cancer Research
  Gene Regulation and Chromosome Biology Laboratory
  Molecular Information Theory Group
  Frederick, Maryland  21702-1201
  schne...@mail.nih.gov
  https://schneider.ncifcrf.gov (current link)
  https://alum.mit.edu/www/toms (permanent link)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Schneider
Sven:

> -Sg only enables intrafunction gotos if they should be disabled (don't
> remember which mode disables them...)

Ok, so that's out.

> > Is there a (non standard!) exit function in fpc that I could use
> > during compilation?  (Then I could substitute it for the goto call
> > before compiling.)
> 
> I'd suggest you to use Halt(ErrorCode) instead. It's defined in unit
> system.

That worked, thanks.  Of course I had to rename my 'halt' proceedure
something else.  It would be possible to modify the program this way. 
But the next email nailed it ...

Tom

  Thomas D. Schneider, Ph.D.
  Senior Investigator
  National Institutes of Health
  National Cancer Institute
  Center for Cancer Research
  Gene Regulation and Chromosome Biology Laboratory
  Molecular Information Theory Group
  Frederick, Maryland  21702-1201
  schne...@mail.nih.gov
  https://schneider.ncifcrf.gov (current link)
  https://alum.mit.edu/www/toms (permanent link)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Mark Morgan Lloyd

Schneider wrote:

Folks:

https://alum.mit.edu/www/toms/ftp/shell.p


Shows up as a bad link here.

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

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


Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Sven Barth
Am 09.10.2015 12:34 schrieb "Schneider" :
>
> Folks:
>
> https://alum.mit.edu/www/toms/ftp/shell.p

I've now looked at your example code a bit more. Using 3.0.0 (or in my case
3.1.1) it compiles if you pass -Miso as parameter. Getting it to run
confuses me a bit however considering that I've never worked with ISO style
input/output files. ;) Please note that support for such files is new
(introduced with 3.0.0) and thus might be buggy. If you find any problems
with them it would be nice if you report them. :)

As an addendum to my previous mail: one can set singular modeswitches using
-Mxxx as well (e.g. -Mnonlocalgoto), these are however overridden if a mode
directive in the code is encountered.

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


Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Jonas Maebe


Sven Barth wrote on Fri, 09 Oct 2015:


Am 09.10.2015 12:34 schrieb "Schneider" :


Folks:

https://alum.mit.edu/www/toms/ftp/shell.p


I've now looked at your example code a bit more. Using 3.0.0 (or in my case
3.1.1) it compiles if you pass -Miso as parameter. Getting it to run
confuses me a bit however considering that I've never worked with ISO style
input/output files. ;) Please note that support for such files is new
(introduced with 3.0.0) and thus might be buggy. If you find any problems
with them it would be nice if you report them. :)


The support for ISO-style input/output files was fixed in trunk after  
3.0 was branched (in r30757), so I'm afraid it won't work yet in 3.0...



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


Re: [fpc-devel] goto illegal in fpc?

2015-10-09 Thread Sven Barth
Am 09.10.2015 12:34 schrieb "Schneider" :
>
> Folks:
>
> https://alum.mit.edu/www/toms/ftp/shell.p
>
> This is a test program I use to check Pascal compilers.  I could not
> figure out from the FPC site how "standard" it is.  When I try to
> compile shell.p, I get:
>
> % fpc shell.p
> Free Pascal Compiler version 2.6.4 [2015/10/07] for x86_64
> Copyright (c) 1993-2014 by Florian Klaempfl and others
> Target OS: Darwin for x86_64
> Compiling shell.p
> shell.p(211,1) Error: Goto statements aren't allowed between different
procedures
> shell.p(234) Fatal: There were 1 errors compiling module, stopping
> Fatal: Compilation aborted
> Error: /sw/bin/ppcx64 returned an error exitcode (normal if you did not
specify a source file to be compiled)
>
> The use of the goto is to escape the program when it detects an
> unresolvable error.  I use ONLY ONE goto in a 'halt' proceedure and
> that gives a message and then does a goto to the end of the program.
>
> As far as I know, jumping out of a procedure like this is standard
> Pascal.  Many of my programs use this mechanism, so if it is not
> allowed, I will be forced to abandon FPC.

By default Free Pascal only allows gotos inside the same function (and even
there with a few restrictions) (the compiler follows Delphi and AFAIK also
Turbo Pascal here). This is because goto is quite destructive regarding
some newer language features that require cleanup. That said there is the
modeswitch "nonlocalgoto" that you can enable (AFAIK that needs FPC 3.0.0
or newer).
Just add "{$modeswitch nonlocalgoto}" add the top of your program after any
other mode directive (AFAIK there is also a possibility to set modeswitches
on the command line).
AFAIK mode MacPas has that switch set by default (at least mode ISO does),
so it might also help to add "{$mode macpas}" or add -Mmacpas as a
parameter. This should also solve other compatibility problems.

> (Note:  I never need goto for any other code so being forced to have
> gotos stay within a single proceedure seems to make goto totally
> useless.)
>
> I thought that the -Sg flag would allow this but it didn't help.

-Sg only enables intrafunction gotos if they should be disabled (don't
remember which mode disables them...)

>
> Is there a (non standard!) exit function in fpc that I could use
> during compilation?  (Then I could substitute it for the goto call
> before compiling.)

I'd suggest you to use Halt(ErrorCode) instead. It's defined in unit system.

Alternatively you could use the exception handling mechanisms that FPC
"inherited" from Delphi.

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


[fpc-devel] goto illegal in fpc?

2015-10-09 Thread Schneider
Folks:

https://alum.mit.edu/www/toms/ftp/shell.p

This is a test program I use to check Pascal compilers.  I could not
figure out from the FPC site how "standard" it is.  When I try to
compile shell.p, I get:

% fpc shell.p
Free Pascal Compiler version 2.6.4 [2015/10/07] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling shell.p
shell.p(211,1) Error: Goto statements aren't allowed between different 
procedures
shell.p(234) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /sw/bin/ppcx64 returned an error exitcode (normal if you did not specify 
a source file to be compiled)

The use of the goto is to escape the program when it detects an
unresolvable error.  I use ONLY ONE goto in a 'halt' proceedure and
that gives a message and then does a goto to the end of the program.

As far as I know, jumping out of a procedure like this is standard
Pascal.  Many of my programs use this mechanism, so if it is not
allowed, I will be forced to abandon FPC.

(Note:  I never need goto for any other code so being forced to have
gotos stay within a single proceedure seems to make goto totally
useless.)

I thought that the -Sg flag would allow this but it didn't help.

Is there a (non standard!) exit function in fpc that I could use
during compilation?  (Then I could substitute it for the goto call
before compiling.)

I used fink to install fpc.  I'm on OS X 10.10.5.  Since I just
started, I'm not on the fpc list yet, so please include my email in
responses.

Thanks,

Tom

  Thomas D. Schneider, Ph.D.
  Senior Investigator
  National Institutes of Health
  National Cancer Institute
  Center for Cancer Research
  Gene Regulation and Chromosome Biology Laboratory
  Molecular Information Theory Group
  Frederick, Maryland  21702-1201
  schne...@mail.nih.gov
  https://schneider.ncifcrf.gov (current link)
  https://alum.mit.edu/www/toms (permanent link)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel