Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-09

FPC 2.2.3 i386-darwin snapshot

16 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

Could someone please upload 1 snapshot of the latest FPC 2.2.3 to ftp://ftp.freepascal.org/pub/fpc/snapshot/fixes/i386-macosx/ ? I would be imensely grateful.

I am writing an article about PasCocoa and I need a fix for static methods, and also a publicly available installer with the fix.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Florian Klaempfl
to Felipe Monteiro de Carvalho
Show quoted text 5 lines
Hello, Could someone please upload 1 snapshot of the latest FPC 2.2.3 to ftp://ftp.freepascal.org/pub/fpc/snapshot/fixes/i386-macosx/ ? I would be imensely grateful.

Try to repeat the static keyword in the body, this could work with 2.2.0 too.

Show quoted text 5 lines
I am writing an article about PasCocoa and I need a fix for static methods, and also a publicly available installer with the fix. thanks,

Reply by email

Felipe Monteiro de Carvalho
to Florian Klaempfl
Florian Klaempfl wrote
Try to repeat the static keyword in the body, this could work with 2.2.0 too.

That was the first thing I tryed:

controller.pas(85,97) Error: Procedure directive "STATIC" not allowed
in implementation section

with fpc 2.2.2

In 2.2.0 the previous static fix isn't present, so I would hit other problems. Cocoa really requires overriding methods (with correct parameters) to do trivial tasks, such as creating a toolbar, so I can't run from this, unless I give up object-orientation and write everything as procedures.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Jonas Maebe
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
How would I procede to create the snapshot myself? I really need it. I cannot create toolbars in Cocoa without static.

How did this error get into 2.2.2 in the first place? All I remember about static is that you explicitly asked for a particular revision to be merged a couple of weeks before the release, also because you needed it for Cocoa. Did you ask for a merge without testing either before or afterwards? If so, I really hope you won't do that again in the future, because it completely destroys the value of release candidates.

Jonas

Reply by email

Felipe Monteiro de Carvalho
to Jonas Maebe

I did not test the merged revision in 2.2.1. Yes, I regret nor having tested it. I had supposed it would work and it was merged right in the end of the development process, so I had no time to test.

But it doesn't matter. In 2.2.0 it accepts the code but it produces wrong parameters, so what is the use for that? Both parts need to work for PasCocoa.

Felipe Monteiro de Carvalho

Reply by email

Jonas Maebe
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
I did not test the merged revision in 2.2.1. Yes, I regret nor having tested it. I had supposed it would work and it was merged right in the end of the development process, so I had no time to test.

In such cases you should never ask to merge things. "Supposing that it will work" is not good enough for a release.

But it doesn't matter. In 2.2.0 it accepts the code but it produces wrong parameters, so what is the use for that?

It did not produce "wrong parameters". The behaviour was not Delphi- compatible, but as long as you did not depend on not having exactly the same kinds of parameters as there (which is probably the case for most code), it worked.

Both parts need to work for PasCocoa.

The result is that now PasCocoa nor other apps that use this work with 2.2.2.

Jonas

Reply by email

Jonas Maebe
to Felipe Monteiro de Carvalho: Could someone please upload 1 snapshot of the latest FPC 2.2.3 to…
Felipe Monteiro de Carvalho wrote 6 lines
Could someone please upload 1 snapshot of the latest FPC 2.2.3 to ftp://ftp.freepascal.org/pub/fpc/snapshot/fixes/i386-macosx/ ? I would be imensely grateful. I am writing an article about PasCocoa and I need a fix for static methods, and also a publicly available installer with the fix.

FWIW, I just discovered that it does not fully work in 2.2.4 either (or 2.3.1, for that matter). This does not compile:

$cat tt.pp
{$mode objfpc}
type
  tc = class
    class procedure a; cdecl; static;
    class procedure b; cdecl; static;
  end;
class procedure tc.a; cdecl; static;
begin
  writeln('a');
end;
class procedure tc.b; cdecl; static;
begin
  a;
end;
begin
  tc.b;
end.

$ fpc -St tt.pp
Free Pascal Compiler version 2.2.4 [2009/03/07] for i386 Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Darwin for i386
Compiling tt.pp
tt.pp(17,4) Error: Illegal expression
tt.pp(23) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted

I.e., you cannot call one static class method from inside another one (removing the "static" makes it compile).

Jonas

Reply by email

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote
Is there any actuall use of cdecl object methods?

The problem is not the cdecl, but the static. And the use of these methods (with both static and cdecl) is that they behave exactly the same as regular C functions/procedures as far as parameter passing is concerned, so you need them currently if you want to declare a method as part of a class that can be passed as call back to C/Objective-C code (see e.g. pascocoa/examples/texteditor/mytoolbar.pas)

Jonas

Reply by email

dmitry boyarintsev
to Jonas Maebe

yeah, i've seen description of 'static' usage at the mailing list (subj: crashing _self parameter)

This is a new feature for FPC, right? (catching up with new delphi syntax?) a few questions about that:
1) 'static' methods are regular procedures/functions, but bound to a class rather than a unit?

2) it's possible to pass 'static'-methods as procedure variables?

TMyObject = class
  class procedure MyMethod; static;
end;
TProc = procedure;
procedure MyProc;
begin
  ...
end;
procedure DoSomething(CallBack: TProc);
begin
  Callback(); // call here
end;
begin
  DoSomething(@MyProc); // it's possible
  DoSomething(@TMyObject.MyMethod); //it's possible either, with no
extra type casting.
end.

3) only class methods can be 'static'? it's impossible to declare a method like:
TMyObject = class

  procedure MyMethod; static;

end;

4) no Self parameter is available inside the 'static' method. (since it's regular procuder or function)

5) 'static' keyword is used only if compiler -St switch specified?

6) how are they actually named? because there're two kind of static methods available:

TMyObject = class
   class function MyClassProc;  // static class method
   class function MyClassVirtualProc; virtual; // virtual class
method. can be overriden.
   class function MyClassVirtualProc; dynamic; // dynamic class
method. can be overriden too
   class function MyClassProc; static; // "static" class method?
end;

Thanks,
Dmitry

Reply by email

Jonas Maebe
to dmitry boyarintsev: yeah, i've seen description of 'static' usage at the mailing list (subj: crashing _self…
dmitry boyarintsev wrote 5 lines
yeah, i've seen description of 'static' usage at the mailing list (subj: crashing _self parameter) This is a new feature for FPC, right? (catching up with new delphi syntax?)

The static keyword been available forever in FPC (probably from before Delphi had it, we first used it in TP-style objects). What is new is making the behaviour of adding of "static" to class methods Delphi- compatible.

a few questions about that: 1) 'static' methods are regular procedures/functions, but bound to a class rather than a unit?

A class method becomes indeed a regular function/procedure within the scope of a class if you add "static;".

2) it's possible to pass 'static'-methods as procedure variables?

Try it. I don't know. It will probably cause compiler errors because of type incompatibilities. If Delphi accepts it in some form, please file a bug report with a compilable example program. It should probably also be tested that class methods are not assignable to a "procedure of object"-style procvar (although I don't know whether that's normally possible for class methods).

Show quoted text 5 lines
3) only class methods can be 'static'? it's impossible to declare a method like: TMyObject = class procedure MyMethod; static; end;

It's possible to declare this, but it doesn't change anything currently (a method without self-parameter would be indistinguishable from a class method without its hidden vmt-parameter -- which is also called self, for that matter). I don't see any use for this.

4) no Self parameter is available inside the 'static' method. (since it's regular procuder or function)

That's the whole point of using static.

5) 'static' keyword is used only if compiler -St switch specified?

Yes, or {$static on)

Show quoted text 5 lines
6) how are they actually named? because there're two kind of static methods available: TMyObject = class class function MyClassProc; // static class method

This is a regular class method.

Show quoted text 5 lines
class function MyClassVirtualProc; virtual; // virtual class method. can be overriden. class function MyClassVirtualProc; dynamic; // dynamic class method. can be overriden too class function MyClassProc; static; // "static" class method?

And this is a static class method.

7) 'static' keyword is available for both {$mode objfpc} and {$mode delphi}

It's available in every mode, as long as you add -St or {$static on}

Jonas

Reply by email

Travis Siegel
to Jonas Maebe: FWIW, I just discovered that it does not fully work in 2.2.4 either (or 2.3.1, for that…

You've gotten farther than I did.
I can't get anything from pascocoa to compile, it complains about missing units.
And the missing units are not included in the pascocoa sources, so no idea where to get them.
(don't remember which unit is missing, will check later and write again) What did you do to get pascocoa to work under osx?

Jonas Maebe wrote 55 lines
On 29 Sep 2008, at 01:48, Felipe Monteiro de Carvalho wrote: > Could someone please upload 1 snapshot of the latest FPC 2.2.3 to > ftp://ftp.freepascal.org/pub/fpc/snapshot/fixes/i386-macosx/ ? I > would > be imensely grateful. > > I am writing an article about PasCocoa and I need a fix for static > methods, and also a publicly available installer with the fix. FWIW, I just discovered that it does not fully work in 2.2.4 either (or 2.3.1, for that matter). This does not compile: $cat tt.pp {$mode objfpc} type tc = class class procedure a; cdecl; static; class procedure b; cdecl; static; end; class procedure tc.a; cdecl; static; begin writeln('a'); end; class procedure tc.b; cdecl; static; begin a; end; begin tc.b; end. $ fpc -St tt.pp Free Pascal Compiler version 2.2.4 [2009/03/07] for i386 Copyright (c) 1993-2008 by Florian Klaempfl Target OS: Darwin for i386 Compiling tt.pp tt.pp(17,4) Error: Illegal expression tt.pp(23) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted I.e., you cannot call one static class method from inside another one (removing the "static" makes it compile). Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email