renan-guimaraes / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Each type definition requires a separate "type" keyword #393

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have script:

--------------------------------
unit Tst;

type

 TSomeType = class
 end;

 TOtherType = class
 end; 

begin
end;
--------------------------------

Compilation returns an error:

Syntax Error: Unknown name "TOtherType" [line 8, column: 2]

After adding a second keyword "type" before TOtherType error disappears:

--------------------------------
type
 TSomeType = class
 end;

type
 TOtherType = class
 end; 
--------------------------------

Original issue reported on code.google.com by jac....@gmail.com on 15 May 2013 at 10:45

GoogleCodeExporter commented 9 years ago
This is "as designed", when you don't have the "interface" keyword, the units 
follow the "consolidated" syntax, in which you can mix declarations & 
implementations, and where methods can have their implementation inline. 
However for this yo work, this requires having "type" for each declaration (and 
same goes for "const" & "var").

If you specify "interface", then the unit will follow the classic Delphi 
syntax, with type/var/const sections, and a (required) implementation.

Original comment by zar...@gmail.com on 15 May 2013 at 1:47