Recent

Author Topic: [OBSOLETE] string as formal parameter, but disallow extended syntax  (Read 2990 times)

Kays

  • Full Member
  • ***
  • Posts: 182
  • Whasup!?
    • KaiBurghardt.de
Hi,

I wanted to forbid extended syntax, but it broke my unit though. ☹  I've narrowed it down, what FPC doesn't like. Here a minimal *non* working example:
Code: Pascal  [Select]
  1. unit mnwe;
  2.  
  3. {$mode objfpc}
  4.  
  5. {$extendedsyntax off}
  6.  
  7. interface
  8. type
  9.     myClass = class
  10.         private
  11.             someField: string;
  12.         public
  13.             constructor init(someParameter: string);
  14.     end;
  15.  
  16. implementation
  17.  
  18. constructor myClass.init(someParameter: string);
  19. begin
  20.     if length(someParameter) < 1 then
  21.     begin
  22.         fail;
  23.     end;
  24.     someField := someParameter;
  25. end;
  26.  
  27. end.

Compilation aborts with
Code: [Select]
Free Pascal Compiler version 2.6.4+dfsg-8 [2015/08/14] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling mnwe.pas
mnwe.pas(19,1) Error: Operation ">" not supported for types "Pointer" and "Pointer"
mnwe.pas(28) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled
Which is quite irritating as I'm not using any >-comparisons or pointers.

*Why* aren't strings allowed as parameters? (while forbidding extended syntax)
« Last Edit: March 06, 2016, 04:34:54 am by Kays »
Yours Sincerely
Kai Burghardt

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: string as formal parameter, but disallow extended syntax
« Reply #1 on: March 06, 2016, 03:14:03 am »
Makes any difference with adding const?
Code: Pascal  [Select]
  1. constructor init(const someParameter: string);

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: string as formal parameter, but disallow extended syntax
« Reply #2 on: March 06, 2016, 03:14:11 am »
Code: Pascal  [Select]
  1. Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
  2. Copyright (c) 1993-2015 by Florian Klaempfl and others
  3. Target OS: Win32 for i386
  4. Compiling G:\users\molly\mnwe.pas
  5. 26 lines compiled, 0.1 sec
btw you can use code=pascal tag to show linenumbers, or use the # insert code icon inside the editor

edit:
sorry, better to speak out: that implies same code also fails for me with exact same error message with 2.6.4 compiler.
« Last Edit: March 06, 2016, 03:22:48 am by molly »

Kays

  • Full Member
  • ***
  • Posts: 182
  • Whasup!?
    • KaiBurghardt.de
Re: string as formal parameter, but disallow extended syntax
« Reply #3 on: March 06, 2016, 03:26:16 am »
Makes any difference with adding const? […]
Nope. Still fails.

[… FPC compiled the mwne.pas on molly's PC …]
btw you can use code=pascal tag to show linenumbers, or use the # insert code icon inside the editor
Uh-huh. I haven't allowed JS, yet, so no fancy buttons for me.
You're using FPC 3.0.0. Mhh. Is there a deb repository with an up to date FPC?

Anyway. Why doesn't it work (possibly referring what's going on under the hood)?
Yours Sincerely
Kai Burghardt

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: string as formal parameter, but disallow extended syntax
« Reply #4 on: March 06, 2016, 03:35:18 am »
[… FPC compiled the mwne.pas on molly's PC …]
btw you can use code=pascal tag to show linenumbers, or use the # insert code icon inside the editor
Uh-huh. I haven't allowed JS, yet, so no fancy buttons for me.
that's why i mentioned both options ;-) (forgive me not using brackets -> that would screw up the post  :D


Quote
Anyway. Why doesn't it work (possibly referring what's going on under the hood)?
I've added to my answer to make it hopefully more clear. Probably simply a bug/oversight that got fixed.

Quote
Mhh. Is there a deb repository with an up to date FPC?
https://packages.debian.org/search?keywords=fpc ?

Kays

  • Full Member
  • ***
  • Posts: 182
  • Whasup!?
    • KaiBurghardt.de
Re: string as formal parameter, but disallow extended syntax
« Reply #5 on: March 06, 2016, 03:44:50 am »
https://packages.debian.org/search?keywords=fpc ?
Of course, more recent versions might be in sid or testing. Not what I meant, though, as I'm not gonna include them. Some projects maintain a repository (or PPA) on their own providing most recent versions.

So it is, errm, /was/ a bug.
Yours Sincerely
Kai Burghardt

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: string as formal parameter, but disallow extended syntax
« Reply #6 on: March 06, 2016, 03:57:17 am »
Of course, more recent versions might be in sid or testing. Not what I meant, though, as I'm not gonna include them. Some projects maintain a repository (or PPA) on their own providing most recent versions.
Official FPC download page states:
Quote
Deb archives for 3.0.0 are not available from us. Please refer to the official Debian experimental repository instead.
So, unfortunately i can't seem to help you out there.  :(

Quote
So it is, errm, /was/ a bug.
Seems that way. sorry, i couldn't be bothered to look for it in the bugtracker (no idea where to search for, but maybe you can work out the correct search phrase to find).