Re: [fpc-devel] compile problems with fpc: linking issue
Schneider wrote on Fri, 09 Oct 2015: Thanks for the explanation! Now for the next problem ... If it's about errors when enabling the generation of debug information: use -gw rather than -g. That same change in Xcode 7 also removed support for the Stabs debugging format, which is the default for Darwin/i386 in FPC 2.6.4. That, too, will be solved in FPC 3.0rc2. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] compile problems with fpc: linking issue
Schneider wrote: Folks: Linking hello ld: warning: object file (hello.o) was built for newer OSX version (10.10) than being linked (10.5) ld: warning: object file (/sw/lib/fpc/2.6.4/units/x86_64-darwin/rtl/system.o) was built for newer OSX version (10.9) than being linked (10.5) 5 lines compiled, 0.1 sec 27% Why is this happening? I'm on OS X 10.10.5. It is due to Xcode 7, which encodes the target OS X version in every object file. If none is specified, it uses the host OS version (10.10 in your case). Previous versions of Xcode did not encode this OS X version in object files (its assembler did not even have an option to do so). The linker, however, did support specifying the target OS X version, so FPC has used that option since a long time (and 10.4 is FPC's default target OS version for i386 binaries). The warning is completely benign in case of FPC, because the compiler currently never uses OS-version-specific constructs in object files, and you can ignore it. With FPC 3.0rc2 and later, the warning will be gone altogether. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] compile problems with fpc: linking issue
Jonas: > The warning is completely benign in case of FPC, because the compiler > currently never uses OS-version-specific constructs in object files, and you > can ignore it. > > With FPC 3.0rc2 and later, the warning will be gone altogether. Thanks for the explanation! Now for the next problem ... Tom ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
Michael Van Canneyt wrote: On Fri, 9 Oct 2015, Sven Barth wrote: Am 08.10.2015 23:48 schrieb "Michael Van Canneyt": Actually, yes I think C's or Javascript's ternary is better suited. Let me explain. If I see If expr1 then expr2 else expr3 it says 'statement' to me. But a ? b : c; Says "expression" to me. So left := a ? b : c; That's probably only because other languages use that as the ternary. No, it is because there are no keywords involved. The keyword "If" starts a statement. It's a simple rule. As I said: by using "if" in an expression, you break the rule and introduce ambiguity. There also another reason why I prefer the variant with the if: ease to implement in the compiler. For the if one merely needs to add a corresponding case in factor() while for the ?: one needs to fiddle with the compiler's operator precedence rules that are applied in sub_expr() which can lead to desaster either during implementation or later on when bugs are discovered... I don't see how the use of "if" differs from "?" in rules of precedence, they are at the exact same level. They're both just tokens to the compiler. At least "?" has the advantage of being new and not yet used, so is unambiguously. Jonas, what's your take on this as an overall language guru? -- 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
[fpc-devel] Pascal Smart Pointers Idea + ARC implementation
I am working on smart pointers for FPC (something more than pure ARC for classes). This solution is full compatible with existing code base. I would like to know what do you think about my conception and work. First step is almost done -> new record operators: === begin code === {$MODESWITCH MANAGEMENTOPERATORS} type // Record with automatic constructor and destructor TValue = record class operator Initialize(var aRec: TValue); class operator Finalize(var aRec: TValue); class operator Copy(constref aSource: TValue; var aDest: TValue); end; === end code === MANAGEMENTOPERATORS are quite simple to implement. MANAGEMENTOPERATORS were created initially for fast implementation of TValue in RTTI.pas, but they inspired me for smart pointers. The second step is some concept of low level structures for smart pointers (in this conception we have two kinds of smart pointers - smart pointers for objects and smart pointers for pointers): === code begin === PRawSmartPtr = ^TRawSmartPtr; TRawSmartPtr = record private FInstance: Pointer; FRefCount: PLongint; function GetInstance: Pointer; function GetRefCount: Longint; public property Instance: Pointer read GetInstance; property RefCount: Longint read GetRefCount; end; PRawSmartObj = ^TRawSmartObj; TRawSmartObj = type TRawSmartPtr; function TRawSmartPtr.GetInstance: Pointer; begin if (FRefCount = nil) or (FRefCount^ <= 0) then Exit(nil); Result := FInstance; end; function TRawSmartPtr.GetRefCount: Longint begin if FRefCount = nil then Exit(0); Result := FRefCount^; end; === code end === For smart pointers we need to implement in some way ".", standard inplicit opertor, "^", "@" and "@@" operator. I thought about it for a long time. IMO minimal invasive method is "default" keyword, used as below: === code begin === TSmartPtr = record // similar as overloading [] operators for property x[v: string]: integer read gx write sx; default; Instance: ^T; default; // default keyword for non property, can be used only for field of pointer type. RefCount: PLongint; class operator Initialize(var aRec: TSmartPtr); class operator Finalize(var aRec: TSmartPtr); class operator Copy(constref aSource: TSmartPtr; var aDest: TSmartPtr); // implicit or explicit operator should be used before "default" field operator Implicit(constref aValue: T); // special version of Implicit/Explicit is also needed (available only when is used default for field) operator Explicit: TRawSmartPtr; end; class operator TSmartPtr.Initialize(var aRec: TSmartPtr); begin aRec.RefCount := nil; end; class operator TSmartPtr.Finalize(var aRec: TSmartPtr); begin if aRec.RefCount <> nil then if InterLockedDecrement(aRec.RefCount^)=0 then begin Dispose(aRec.RefCount); Dispose(aRec.Instance); end; end; class operator TSmartPtr.Copy(constref aSource: TSmartPtr; var aDest: TSmartPtr); begin if aDest.RefCount <> nil then Finalize(aDest); if aSource.RefCount <> nil then InterLockedIncrement(aSource.RefCount^); aDest.RefCount := aSource.RefCount; aDest.Instance := aSource.Instance; end; operator TSmartPtr.Implicit(constref aValue: T); begin if aDest.RefCount <> nil then Finalize(aDest); New(RefCount); RefCount^ := 0; InterLockedIncrement(RefCount^); Instance := @aValue; end; operator TSmartPtr.Explicit: TRawSmartPtr; begin Result.RefCount := RefCount; Result.Instance := Instance; end; === code end === TSmartObj is very similar to TSmartPtr, the difference exist inside Finalize - where is called Instance^.Free method instead of Dispose(aRec.Instance). few examples: === code begin === simple use case var myObj: TSmartObj; begin // <- call Initialize operator myObj := TObject.Create; // <- call Implicit operator end; // <- call Finalize operator. Dec(RefCount) and if RefCount = 0 then call Instance^.Free === code end === === code begin === smart pointer and exceptions var myObj: TSmartObj; begin // <- call Initialize operator myObj := TObject.Create; // <- call Implicit operator try // we don't need try-finally-end anymore because operator Finalize is always called WriteLn(myObj.ClassName); // will print TObject. Equivalent of WriteLn(p.Instance^.ClassName); raise Exception.Create('Error Message'); except end; end; // <- call Finalize operator. Dec(RefCount) and if RefCount = 0 then call Instance^.Free === code end === === code begin === access to TSmartObj/TSmartPtr var p: TSmartPtr; begin // <- call Initialize operator WriteLn(TRawSmartPtr(p).RefCount); // <-- call Explicit . Will print 0 p := New(PInteger); // <-- call Implicit p^ := 10; // use "default" magic, equivalent of p.Instance^^ := 10 WriteLn(Assigned(p)); // will print true, equivalent of WriteLn(Assigned(p.Instance^)); WriteLn(TRawSmartPtr(p).RefCount); // <-- call Explicit . Will print 1 end; // <- call Finalize operator.
Re: [fpc-devel] Proof of Concept ARC implementation
Am 09.10.2015 19:29 schrieb "FabrÃcio Srdic": > > Any progress to ARC implementation? Not much feedback here... Also not every core developer agrees with the approach I've taken and at least with a feature as fundamental as this I'd like to have at least /some/ consens... Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
Am 09.10.2015 20:29 schrieb "Michael Van Canneyt": > > > > On Fri, 9 Oct 2015, Dmitry Boyarintsev wrote: > >> The only Pascal way is >> >> left := IfThen(expr1, expr2, expr3) >> >> Similar to addr(), sizeof(), length(), write() and recently added Default() >> in intrinsic. >> I guess functions declared in Math unit are not covering all the needs >> (since type of expr2, expr3) may vary. >> That's why a bit of compiler support is needed. > > > The main reason compiler support is needed is that Expr3 must not be evaluated if expr1 is true, and expr2 must not be evaluated if expr1 is false, at least if you want the ternary semantics. (as once explained to me by Sven himself...) > > I'm not sure this kind of semantics is possible with a compiler intrinsic... > But if it is: In that case the IfThen or IIF() or somesuch has my absolute top preference, followed by ternary. (and the If .. then expression should be blasted to hell ;) ) Yes a compiler intrinsic could handle that. In the end all three syntaxes are the same code representation anyway: namely an if-node. The IfThen() intrinsic would be fine with me as well. Let's call this our common ground ;) Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
On Fri, Oct 9, 2015 at 5:04 PM, Sven Barthwrote: > Yes a compiler intrinsic could handle that. In the end all three syntaxes > are the same code representation anyway: namely an if-node. > The IfThen() intrinsic would be fine with me as well. Let's call this our > common ground ;) > I wonder if replacing Ifthen() inline function, with a common intrinsic keeps the compatibility. Just because it is "inline" in the end, the generated code forced the proper order of valuation: condition goes first at then the proper expression. However, "inline" is just a hint, rather than a rule for the compiler. And if there's a place, where the function was not inlined, then the compatibility might break. ... causing to think about a different name. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
Am 08.10.2015 23:48 schrieb "Michael Van Canneyt": > Actually, yes I think C's or Javascript's ternary is better suited. > > Let me explain. If I see > > If expr1 then expr2 else expr3 > > it says 'statement' to me. But > > a ? b : c; > > Says "expression" to me. > > So > > left := a ? b : c; That's probably only because other languages use that as the ternary. There also another reason why I prefer the variant with the if: ease to implement in the compiler. For the if one merely needs to add a corresponding case in factor() while for the ?: one needs to fiddle with the compiler's operator precedence rules that are applied in sub_expr() which can lead to desaster either during implementation or later on when bugs are discovered... So that's another reason why I'm inclined to this... (Also that Algol-60 as the spiritual predecessor of Pascal has them as well is quite intriguing :) ) Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
On Fri, 9 Oct 2015, Sven Barth wrote: Am 08.10.2015 23:48 schrieb "Michael Van Canneyt": Actually, yes I think C's or Javascript's ternary is better suited. Let me explain. If I see If expr1 then expr2 else expr3 it says 'statement' to me. But a ? b : c; Says "expression" to me. So left := a ? b : c; That's probably only because other languages use that as the ternary. No, it is because there are no keywords involved. The keyword "If" starts a statement. It's a simple rule. As I said: by using "if" in an expression, you break the rule and introduce ambiguity. There also another reason why I prefer the variant with the if: ease to implement in the compiler. For the if one merely needs to add a corresponding case in factor() while for the ?: one needs to fiddle with the compiler's operator precedence rules that are applied in sub_expr() which can lead to desaster either during implementation or later on when bugs are discovered... I don't see how the use of "if" differs from "?" in rules of precedence, they are at the exact same level. They're both just tokens to the compiler. At least "?" has the advantage of being new and not yet used, so is unambiguously. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] compile problems with fpc: linking issue
Folks: I used fink to install fpc. 25% cat hello.p program hello(output); (* hello: tiny Pascal program *) begin writeln(output,'hello'); end. 26% fpc hello.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 hello.p Assembling (pipe) hello.s Linking hello ld: warning: object file (hello.o) was built for newer OSX version (10.10) than being linked (10.5) ld: warning: object file (/sw/lib/fpc/2.6.4/units/x86_64-darwin/rtl/system.o) was built for newer OSX version (10.9) than being linked (10.5) 5 lines compiled, 0.1 sec 27% Why is this happening? I'm on OS X 10.10.5. Note: Since I just started, I'm not on the fpc list yet, so please include my email in responses. 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] new features and facilities
On Fri, 9 Oct 2015, Sven Barth wrote: I'm not sure this kind of semantics is possible with a compiler intrinsic... But if it is: In that case the IfThen or IIF() or somesuch has my absolute top preference, followed by ternary. (and the If .. then expression should be blasted to hell ;) ) Yes a compiler intrinsic could handle that. In the end all three syntaxes are the same code representation anyway: namely an if-node. The IfThen() intrinsic would be fine with me as well. Let's call this our common ground ;) Agreed ! Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
On 10/9/2015 2:39 PM, Schneider wrote: I've been programming in Pascal for more than 30 years. The code has survived numerous computer and operating system switches because I didn't rely on computer- or compiler-specific features. So I'm not at all inclined to trap the programs. These features would have to be available in all Pascal compilers ... but the p2c translator is unlikely to support them and the original author is not responding. So it looks like p2c depends on me for now ... and it's dead Jim (on a Mac). I am programming in Pascal for 39 years now, starting around June/Juli '76 on a Wirth compiler implementation for a PDP-8. That is probably the only time I have used a "standard" compiler for Pascal. All other implementation of Pascal I have used since had been far ahead of what became ISO Pascal, including UCSD Pascal (including Apple Pascal) and later Turbo/Borland Pascal/Delphi. Even Metaware Professional Pascal, which was probably as close to ISO as it has been for me since, allowed for more sane features to make it actually usable. And we used it back in the late '80s/early '90s only to generate more optimized 386 math code for the CAD software we developed, as it had one hell of a 80386 optimizer build in, which a lot of times was beating attempts to produce better code by hand in assembler... Avoiding computer/compiler specific features by sticking to ISO/GPC is just what gets you "trapped" in the days of punch cards and terminal printer output. Ralf --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
Am 09.10.2015 20:14 schrieb "Schneider": > > Tomas: > > > Have you compiled your code with -Miso command line parameter as already > > suggested by someone else? I assume that unit iso7185 providing these > > procedures is then automatically included. If not, you can certainly add > > this unit to your uses clause manually. > > Yes, I'm currently compiling using: > > fpc -Miso -Tdarwin -Mmacpas getput.p You should only pass one of the major modes (which are "fpc", "tp", "iso", "objfpc", "macpas", "delphi" and "delphiunicode") while you can use multiple of the minor modeswitches (I don't know them all by heart so I won't list them here ^^ ). Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
Am 09.10.2015 20:21 schrieb "Schneider": > With 400+ programs, unless I can automate fixes it's not going to be > feasible. (The assigment could probably be done by rebuilding the > source automatically.) > > The issue for me is that I use (almost) strictly standard Pascal and I > could do that using GPC. But GPC on Mac OS X died with the latest Mac > "upgrade" to 10.10.5. The translator p2c now also fails. This puts > me in a bad position because I rely on these programs to do my > science. I'm glad to know that fpc is being developed to handle ISO > support now!! I have to admit that I'm quite impressed that you're using only Standard Pascal (I personally wouldn't want to miss many features of the modern dialects ;) ). In addition you might be the biggest ISO user of FPC yet :) (which will hopefully help to find more bugs in that mode ;) ) Out of interest: are you interested in any Extended Pascal features? Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
Sven: > > fpc -Miso -Tdarwin -Mmacpas getput.p > > You should only pass one of the major modes (which are "fpc", "tp", > "iso", "objfpc", "macpas", "delphi" and "delphiunicode") while you can > use multiple of the minor modeswitches (I don't know them all by heart > so I won't list them here ^^ ). Ok, I switched to: fpc -Miso -Tdarwin $program.p That worked. Not clear whether -Tdarwin should stay ... 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] get/put in fpc
Sven: > I have to admit that I'm quite impressed that you're using only > Standard Pascal (I personally wouldn't want to miss many features of > the modern dialects ;) ). Well, sometimes it's tempting. The only thing that I do violate for some programs is getting the date and time. That's not standard, so I put them into modules that can be replaced automatically (my 'module' program does 'insertions' at the text level). > In addition you might be the biggest ISO user > of FPC yet :) (which will hopefully help to find more bugs in that mode > ;) ) Well, assuming that it gets off the ground and I can compile my programs ... > Out of interest: are you interested in any Extended Pascal features? I've been programming in Pascal for more than 30 years. The code has survived numerous computer and operating system switches because I didn't rely on computer- or compiler-specific features. So I'm not at all inclined to trap the programs. These features would have to be available in all Pascal compilers ... but the p2c translator is unlikely to support them and the original author is not responding. So it looks like p2c depends on me for now ... and it's dead Jim (on a Mac). 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] new features and facilities
Am 08.10.2015 19:51 schrieb "MohsenTi": > > Thank you Sven, > is there any documentation about freepascal compiler parts ? Nope, sorry. It's mainly learning by doing or maybe learning by debugging... 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?
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?
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?
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?
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?
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] new features and facilities
Am 09.10.2015 08:36 schrieb "Michael Van Canneyt": >> There also another reason why I prefer the variant with the if: ease to >> implement in the compiler. >> >> For the if one merely needs to add a corresponding case in factor() while >> for the ?: one needs to fiddle with the compiler's operator precedence >> rules that are applied in sub_expr() which can lead to desaster either >> during implementation or later on when bugs are discovered... > > > I don't see how the use of "if" differs from "?" in rules of precedence, they are at the exact same level. > They're both just tokens to the compiler. At least "?" has the advantage of being new and not yet used, so is unambiguously. The tokens themselves are merely tokens to the compiler, but you need to ensure that expressions like "a + b ? c : d + e" are handled correctly by the compiler (and right now I don't even care what the rules would be exactly, only /that/ they need to be). Though thinking about it one could maybe add the check for the ?-token to the end of factor(), that should hopefully cover all cases... :/ (this does however not mean that I support the syntax ;) ) 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?
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?
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
Re: [fpc-devel] new features and facilities
The only Pascal way is left := IfThen(expr1, expr2, expr3) Similar to addr(), sizeof(), length(), write() and recently added Default() in intrinsic. I guess functions declared in Math unit are not covering all the needs (since type of expr2, expr3) may vary. That's why a bit of compiler support is needed. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proof of Concept ARC implementation
Any progress to ARC implementation? Best regards ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] get/put in fpc
Thanks for everybody's help. I've made some progress in getting my standard Pascal programs to compile under fpc. Now comes a big issue. In standard Pascal, one can use get() and put() to access files. The current file object is accessed with file^. I use this in many places. program getput(shellp, output); var shellp: text; (* file used by this program *) begin Assign (shellp,'shellp'); writeln(output,'getput test is running'); reset(shellp); writeln(output,'first character of shellp: ',shellp^); end. 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 getput.p getput.p(9,56) Error: Illegal qualifier getput.p(11) 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) So shellp^ failed. If I try instead get(shellp); I get: getput.p(12,7) Error: Identifier not found "get" getput.p(14) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted So get and put do not exist in fpc? 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
[fpc-devel] default file asignment in fpc?
Jonas: > 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... Perhaps this is related to my next issue. egg 21% shell shell 3.01 An unhandled exception occurred at $000113CF : EInOutError : File not assigned $000113CF I am able to add this code: Assign (afile,''); Assign (bfile,''); Assign (shellp,''); and then that does not occur. However, when run from the command line the program gets stuck waiting for me. Changing it to: Assign (afile,'afile'); Assign (bfile,'bfile'); Assign (shellp,'shellp'); then the program runs cleanly. In GPC I was able to set it so that the file name assigned is the file string itself. Is there a flag to set this? I want to avoid using 'assign' in my code because it's not standard as far as I know. (I could not find something useful at http://www.freepascal.org/docs-html/user/userap1.html) 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] get/put in fpc
On Fri, October 9, 2015 19:39, Schneider wrote: . . > In standard Pascal, one can use get() and put() to access files. The > current file object is accessed with file^. I use this in many > places. . . > 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 getput.p > getput.p(9,56) Error: Illegal qualifier > getput.p(11) 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) > > So shellp^ failed. > > If I try instead > >get(shellp); > > I get: > > getput.p(12,7) Error: Identifier not found "get" > getput.p(14) Fatal: There were 1 errors compiling module, stopping > Fatal: Compilation aborted > > So get and put do not exist in fpc? Have you compiled your code with -Miso command line parameter as already suggested by someone else? I assume that unit iso7185 providing these procedures is then automatically included. If not, you can certainly add this unit to your uses clause manually. Second, as also mentioned by Jonas, the part of ISO standard support related to file handling has been only fixed recently and is not available in any released version. You might be able to build a newer compiler version from the sources if needed, although I cannot judge how easy or difficult that may get on your platform of choice (but it's certainly doable). Unfortunately, I don't see any ready made snapshots available for your platform on our FTP server - that would have been an easy solution. Tomas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
On 09/10/15 19:39, Schneider wrote: So get and put do not exist in fpc? Not in FPC 2.6.4. They do exist in FPC 3.0rc1, but FPC 3.0rc1 still contains a bug that makes it (wrongfully) complain about a duplicate "SHELLP" identifier with your program (and this bug will also be in the final FPC 3.0 release; it will be fixed in FPC 3.0.2 probably). If you remove the "(shellp,output)" from the program header, the program compiles and runs correctly with FPC 3.0 if you also add a "rewrite(shellp);" after the reset though. In general, ANSI ISO Pascal support is still very new in FPC, because until now virtually everyone wanting ISO support used GPC, and FPC's developers all come from a Turbo Pascal or Delphi background. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
On 09/10/15 20:14, Schneider wrote: http://www.freepascal.org/ Latest News August 25th, 2015 FPC 3.0.0-rc1 has been released! ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1 ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/ ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/fpc-3.0.0rc1.intel-macosx.dmg Is that the right one for me on Mac OS X 10.10.5? Yes, but note that since this a dmg installer rather than a fink package, you will not be able to easily uninstall it afterwards should you wish to do so (there is no problem with having multiple FPC versions installed concurrently and the final FPC 3.0 installer will overwrite the FPC 3.0rc1 files, but it's just something to keep in mind). Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
On Fri, 9 Oct 2015, Dmitry Boyarintsev wrote: The only Pascal way is left := IfThen(expr1, expr2, expr3) Similar to addr(), sizeof(), length(), write() and recently added Default() in intrinsic. I guess functions declared in Math unit are not covering all the needs (since type of expr2, expr3) may vary. That's why a bit of compiler support is needed. The main reason compiler support is needed is that Expr3 must not be evaluated if expr1 is true, and expr2 must not be evaluated if expr1 is false, at least if you want the ternary semantics. (as once explained to me by Sven himself...) I'm not sure this kind of semantics is possible with a compiler intrinsic... But if it is: In that case the IfThen or IIF() or somesuch has my absolute top preference, followed by ternary. (and the If .. then expression should be blasted to hell ;) ) Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
Jonas: > Yes: http://lists.freepascal.org/mailman/listinfo/fpc-announce > It is generally only used to send out announcements of new versions. Done, 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
Re: [fpc-devel] new features and facilities
On Fri, Oct 9, 2015 at 2:30 PM, Michael Van Canneytwrote: I'm not sure this kind of semantics is possible with a compiler intrinsic... > But if it is: In that case the IfThen or IIF() or somesuch has my absolute > top preference, followed by ternary. (and the If .. then expression should > be blasted to hell ;) ) > Here's an example: uses sysutils; var a,b : integer; begin a:=1; b:=5; assert(a=0, 'error: '+intTostr(b)); end. compiled with (2.6.4) fpc -al -Sa testassert.pas Looking at the assembler code, a=0 is evaluated first. If it's true, the code is passed to the next line after assert, w/o evaluating 'error '+intToStr(b). Looks like a good example of conditional intrinsic supported by compiler to me. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] new features and facilities
On Fri, Oct 9, 2015 at 2:45 PM, Dmitry Boyarintsev < skalogryz.li...@gmail.com> wrote: > Looking at the assembler code, a=0 is evaluated first. > If it's true, the code is passed to the next line after assert, w/o > evaluating 'error '+intToStr(b). > And that's the reason why assert() was invented and people love it... as well as -Sa :) thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
Tomas: > Have you compiled your code with -Miso command line parameter as already > suggested by someone else? I assume that unit iso7185 providing these > procedures is then automatically included. If not, you can certainly add > this unit to your uses clause manually. Yes, I'm currently compiling using: fpc -Miso -Tdarwin -Mmacpas getput.p (This is in a script 'fpcc' so I don't forget.) > Second, as also mentioned by Jonas, the part of ISO standard support > related to file handling has been only fixed recently and is not available > in any released version. You might be able to build a newer compiler > version from the sources if needed, although I cannot judge how easy or > difficult that may get on your platform of choice (but it's certainly > doable). Unfortunately, I don't see any ready made snapshots available for > your platform on our FTP server - that would have been an easy solution. Ok, that's what I suspected. http://www.freepascal.org/ Latest News August 25th, 2015 FPC 3.0.0-rc1 has been released! ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1 ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/ ftp://freepascal.stack.nl/pub/fpc/beta/3.0.0-rc1/i386-macosx/fpc-3.0.0rc1.intel-macosx.dmg Is that the right one for me on Mac OS X 10.10.5? Or rather: http://www.freepascal.org/download.var http://www.freepascal.org/down/source/sources.var http://sourceforge.net/projects/freepascal/files/ Looking for the latest version? Download fpc-2.6.4.intel-macosx.dmg (91.1 MB) http://sourceforge.net/projects/freepascal/files/latest/download?source=files ? 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] get/put in fpc
Jonas: > Not in FPC 2.6.4. They do exist in FPC 3.0rc1, but FPC 3.0rc1 still contains > a bug that makes it (wrongfully) complain about a duplicate "SHELLP" > identifier with your program (and this bug will also be in the final FPC 3.0 > release; it will be fixed in FPC 3.0.2 probably). If you remove the > "(shellp,output)" from the program header, the program compiles and runs > correctly with FPC 3.0 if you also add a "rewrite(shellp);" after the reset > though. > > In general, ANSI ISO Pascal support is still very new in FPC, because until > now virtually everyone wanting ISO support used GPC, and FPC's developers > all come from a Turbo Pascal or Delphi background. Thanks for the background. With 400+ programs, unless I can automate fixes it's not going to be feasible. (The assigment could probably be done by rebuilding the source automatically.) The issue for me is that I use (almost) strictly standard Pascal and I could do that using GPC. But GPC on Mac OS X died with the latest Mac "upgrade" to 10.10.5. The translator p2c now also fails. This puts me in a bad position because I rely on these programs to do my science. I'm glad to know that fpc is being developed to handle ISO support now!! Looks like I'll have to wait. Is there an announcement list I could sign up for to get the news when FPC 3.0.2 comes out? 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] get/put in fpc
On 09/10/15 20:21, Schneider wrote: Looks like I'll have to wait. Is there an announcement list I could sign up for to get the news when FPC 3.0.2 comes out? Yes: http://lists.freepascal.org/mailman/listinfo/fpc-announce It is generally only used to send out announcements of new versions. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] get/put in fpc
On 10/09/2015 08:14 PM, Schneider wrote: > > Yes, I'm currently compiling using: > > fpc -Miso -Tdarwin -Mmacpas getput.p I don't know how correct that command line is since you specify two syntax modes: iso (-Miso) and macpas (-Mmacpas). One of those will probably take precedence over the other. Judging from your other messages, you are interested in the iso mode, so try leaving out the -Mmacpas? Just a suggestion, I'm no expert on the compiler. -- Ewald ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] odd date in archive
There is an email address listed at http://lists.freepascal.org/cgi-bin/mailman/listinfo/ If you are having trouble using the lists, please contact mail...@lists.freepascal.org. I sent the following message there: --- At: http://lists.freepascal.org/pipermail/fpc-announce/ The latest archive date is: March 2025 Wow!! Would you mind sending me the plans for that time machine? ;-) --- But it bounced: The following message towas undeliverable. The reason for the problem: 5.1.0 - Unknown address error 550-'5.1.1 : Recipient +address rejected: User unknown in local recipient table' So that's TWO things for you to fix! 1. Date on archive. 2. Mail address failed. 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