Sign in Join

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

Mailing lists / fpc-pascal / 2008-02

Procedures in records not supported :(

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Skybuck Flying

Hello,

Borland pulled a fast one on me ;)

My most recent code uses the new feature "procedures in records".

It seems fpc 2.2.0 does not support procedures in records.

I was hoping fpc 2.2.0 could replace Delphi 2007 compiler because Delphi 2007 compiler is malfunctioning...

I really like this new feature and I simply must must must must must have it ! ;)

// *** Begin of Code ***
unit tweedelul;
interface
type
 Tstinky = record
  a : integer;
  procedure Here;
 end;
implementation
procedure Tstinky.Here;
begin
 a := 5;
end;
end.
// *** End of Code ***
// *** Begin of Output ***

fpc tweedelul.pas -Mdelphi
Free Pascal Compiler version 2.2.0 [2007/09/09] for i386 Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Win32 for i386
Compiling tweedelul.pas
tweedelul.pas(9,3) Fatal: Syntax error, "END" expected but "PROCEDURE" found Fatal: Compilation aborted
Error: C:\Tools\Compilers\Free Pascal\2.2.0 Stable for Win32\bin\i386-Win32\ppc3
86.exe returned an error exitcode (normal if you did not specify a source file t
o be compiled)

// *** End of Output ***

Bye,
Skybuck.

Skybuck Flying
to Milan Marusinec: Hi. Use "object" instead of "record" and you will have also inheritance as a bonus on top…

Not quite buster !

// *** Demo problem begin ***
type
 TmyRecord = record
  A,B,C,D,E,F : integer;
 end;
 TmyObject = object
  A,B,C,D,E,F : integer;
  procedure Test;
 end;
procedure TmyObject.Test;
begin
 A := 5;
end;
begin
 writeln( SizeOf(TmyRecord) );
 writeln( SizeOf(TmyObject) );
 TmyObject.Test; // not allowed, does not compile
end.
// *** Demo problem end ***

The test routine of Tobject cannot be called directly.

It needs probably two things to work:

1. A object instance variable declaration

2. And probably a constructor and destructor call.

This is very bad because it adds much complexity and overhead.

I don't want to manage memory/objects, constructions/destructions.

I just wanna call:

TmyRecord.Test;

Without having to instantiate anything.

That's exactly what Delphi allows me to do.

So it's definetly a new future never seen before ! ;)

And to boldly go where no-one has gone before ! ;) =D

Startrek-tng allll the way baby ;)

Bye,
Skybuck.

Skybuck Flying
to Skybuck Flying: Borland pulled a fast one on me ;) My most recent code uses the new feature "procedures…

Hello,

Delphi allows the following code to be compiled and run:

// *** Begin of Demo ***
program Project1;
{$APPTYPE CONSOLE}

uses
SysUtils,

  Unit1 in 'Unit1.pas';
type
 TmyRecord = record
  A,B,C,D,E,F : integer;
 end;
 TmyObject = record
  A,B,C,D,E,F : integer;
  class procedure Test; static;
 end;
class procedure TmyObject.Test;
begin
 writeln('hi');
end;
begin
 TmyObject.Test;
 readln;
end.
// *** End of Demo ***

Just one of the new features.

Bye,
Skybuck.

Skybuck Flying
to Skybuck Flying: Not quite buster ! // *** Demo problem begin *** type TmyRecord = record A,B,C,D,E,F :…

Hello,

This fpc example seems to do more or less the same as the Delphi static class/record procedure example.

Only extra requirement is to declare a object instance variable and use that to call the test routine.

Less ideal.

type
 TmyRecord = record
  A,B,C,D,E,F : integer;
 end;
 TmyObject = object
  A,B,C,D,E,F : integer;
  procedure Test;
 end;
procedure TmyObject.Test;
begin
 writeln( 'Hi' );
end;
var
 MyObject : TmyObject;
begin
 writeln( SizeOf(TmyRecord) );
 writeln( SizeOf(TmyObject) );
 // TmyObject.Test; // not allowed, does not compile
 MyObject.Test;
end.

Bye,
Skybuck.

Skybuck Flying
to Skybuck Flying: I must correct myself. The code supplied did not compile in Delphi as well. However a…

Interesting.

I posted the new example before I posted the message below.

No nobody will understand which example was the correct one.

A major drawback of using mailing lists ?

Is there anyway I can get some kind of threading going for these e-mails ?

Why not start a usenet server ?

These mails make it very hard to follow a discussion ?!??

Bye,
Skybuck.

Earlier message 23 lines
----- Original Message ----- From: "Skybuck Flying" To: "FPC-Pascal users discussions" Sent: Saturday, February 09, 2008 9:56 PM Subject: Re: [fpc-pascal] Re: Procedures in records not supported :( >I must correct myself. > > The code supplied did not compile in Delphi as well. > > However a similiar design is possible in Delphi so I supplied a new > example in a new posting... > > Anyway I will further explore what it takes to make the object work in fpc > ;) > > Bye, > Skybuck. > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
Milan Marusinec
to Skybuck Flying: Borland pulled a fast one on me ;) My most recent code uses the new feature "procedures…
Skybuck Flying wrote 22 lines
My most recent code uses the new feature "procedures in records". It seems fpc 2.2.0 does not support procedures in records. I was hoping fpc 2.2.0 could replace Delphi 2007 compiler because Delphi 2007 compiler is malfunctioning... I really like this new feature and I simply must must must must must have it ! ;) // *** Begin of Code *** unit tweedelul; interface type Tstinky = record a : integer; procedure Here; end;

Hi.

Use "object" instead of "record" and you will have also inheritance as a bonus on top of that :-)

Recently on this list there was a nice discussion here about object versus record.

PS: I really like the way Borland is making "new" features from the old one ... hehe

Milano

John
to Skybuck Flying: Not quite buster ! // *** Demo problem begin *** type TmyRecord = record A,B,C,D,E,F :…
Skybuck Flying wrote 36 lines
Not quite buster ! // *** Demo problem begin *** type TmyRecord = record A,B,C,D,E,F : integer; end; TmyObject = object A,B,C,D,E,F : integer; procedure Test; end; procedure TmyObject.Test; begin A := 5; end; begin writeln( SizeOf(TmyRecord) ); writeln( SizeOf(TmyObject) ); TmyObject.Test; // not allowed, does not compile end. // *** Demo problem end *** The test routine of Tobject cannot be called directly. It needs probably two things to work: 1. A object instance variable declaration

If you define a record type, you still declare a variable of that type before you use it, don't you ?

2. And probably a constructor and destructor call.

No, not unless you include virtual methods. That is one of the differences between the "old" 'object' definition, introduced in object pascal pre delphi, and the 'class' definition in Delphi.

Show quoted text 8 lines
This is very bad because it adds much complexity and overhead. I don't want to manage memory/objects, constructions/destructions. I just wanna call: TmyRecord.Test;

Do you really want to call the procedure of the record type, or of a variable of that type ?

Show quoted text 13 lines
Without having to instantiate anything. That's exactly what Delphi allows me to do. So it's definetly a new future never seen before ! ;) And to boldly go where no-one has gone before ! ;) =D Startrek-tng allll the way baby ;) Bye, Skybuck.

Re Mail threads, in reply to a different message, I have no trouble seeing the threads in Thunderbird, what mail client are you using ?

cheers,
John Sunderland

Skybuck Flying
to John

Outlook express in combination with hotmail.

I see one big long list of messages all mixed etc.

Anyway to put the messages into message-threads ?

Bye,
Skybuck.

John
to Skybuck Flying
Skybuck Flying wrote 8 lines
Outlook express in combination with hotmail. I see one big long list of messages all mixed etc. Anyway to put the messages into message-threads ? Bye, Skybuck.

Sorry, in that environment, no idea. In Thunderbird it is a sorting option. Perhaps look in that area. I think it is done by looking at the "references" tag in the mail header, you could make sure that exists.

John

Joost van der Sluis
to Skybuck Flying: Interesting. I posted the new example before I posted the message below. No nobody will…

If you wanna chat, use irc. (freenode - #fpc)

Using a mailinglist we force people to think about their problems before they send mails about it. Thus they have to test their code before sending it.

That makes it easier to follow, and improves the changes that people will read the emails. (and maybe even answer them)

If you want classes in a 'fpc-style' you'll need {$mode objfpc}

Joost.

Op zaterdag 09-02-2008 om 22:04 uur [tijdzone +0100], schreef Skybuck Flying:

Show quoted text 45 lines
Interesting. I posted the new example before I posted the message below. No nobody will understand which example was the correct one. A major drawback of using mailing lists ? Is there anyway I can get some kind of threading going for these e-mails ? Why not start a usenet server ? These mails make it very hard to follow a discussion ?!?? Bye, Skybuck. ----- Original Message ----- From: "Skybuck Flying" To: "FPC-Pascal users discussions" Sent: Saturday, February 09, 2008 9:56 PM Subject: Re: [fpc-pascal] Re: Procedures in records not supported :( >I must correct myself. > > The code supplied did not compile in Delphi as well. > > However a similiar design is possible in Delphi so I supplied a new > example in a new posting... > > Anyway I will further explore what it takes to make the object work in fpc > ;) > > Bye, > Skybuck. > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal