[fpc-pascal] Translate C to Pascal

Damien Gerard milipili at shikami.org
Wed Jul 30 22:50:19 CEST 2008


Le Jul 30, 2008 à 10:37 PM, Lourival Mendes a écrit :

> I would do something like this:
>
>
> C
> ----------------------------
> struct product {
>  int weight;
>  float price;
> } ;
>
> product apple;
> -----------------------------
>
> Pascal
> ----------------------------
> Type
>   product = record
>      weight: Integer ;
>      price: double;
>    end;
>
> Var
>  apple: product ;
> ----------------------------
>
> This is the reason that I do believe that is missing something on  
> the code:
>
> struct a;



A C-struct is merely a record. A struct with methods is a class.

struct Foo
{
     Foo() : tag(0) {}
     int tag;
     void compute() {...}
};

would be

class Foo
private
   FTag: Integer;
public
   constructor Create;
   procedure compute;
   property tag: Integer read FTag write FTag;
end;

the property is not really needed of course.


--
Damien Gerard
milipili at shikami.org

Si ces robots s'humanisaient, inversement les êtres humains se  
robotiseraient-ils ?











More information about the fpc-pascal mailing list