fbpx

creating defines using keyword names

  • Karl-Heinz Rauscher
  • Karl-Heinz Rauscher's Avatar Topic Author
  • Offline
More
2 months 3 weeks ago #1 by Karl-Heinz Rauscher
creating defines using keyword names was created by Karl-Heinz Rauscher
i´m wondering why such defines are allowed ?

DEFINE ASSIGN := 11 AS INT
DEFINE FOR := 12 AS INT
DEFINE NEXT := "aa" AS STRING
DEFINE METHOD := 23 AS INT
DEFINE LOOP := 24 AS INT
DEFINE SEQUENCE := 25 AS INT
DEFINE FOREACH := 26 AS INT
DEFINE __ARGLIST := 34 AS INT
DEFINE DEFINE := 36 AS INT
DEFINE INT := 38 AS INT
DEFINE STRING := 40 AS INT
// DEFINE SELF := 41 AS INT // ok, error XS9002: Parser: mismatched input 'SELF'
// DEFINE SUPER := 42 AS INT // ok, error XS9002: Parser: mismatched input 'SUPER'


If i use fully qualified names, i can even access such defines

? speed.exe.Functions.METHOD
? speed.exe.Functions.SEQUENCE
? speed.exe.Functions.__ARGLIST
? speed.exe.Functions.DEFINE
? speed.exe.Functions.INT
? speed.exe.Functions.String
? speed.exe.Functions.next + "bb"


regards
Karl-Heinz

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #2 by Karl Faller
Replied by Karl Faller on topic creating defines using keyword names
IIRC, because the compiler knows positional keywords, i.e., is smart. If it is smart to write such defines is another question <g,d&r>

Karl

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #3 by Robert van der Hulst
Replied by Robert van der Hulst on topic creating defines using keyword names
Karl-Heinz

Positional Keywords...

Robert

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #4 by Chris Pyrgas
Replied by Chris Pyrgas on topic creating defines using keyword names
...and you can use them also almost normally in your code, by prefixing them with @@, in the places where the parser does not allow them:

? @@METHOD

and you can also use this to define a define named "self":

DEFINE @@SELF := 41 AS INT

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Karl-Heinz Rauscher
  • Karl-Heinz Rauscher's Avatar Topic Author
  • Offline
More
2 months 3 weeks ago #5 by Karl-Heinz Rauscher
Replied by Karl-Heinz Rauscher on topic creating defines using keyword names
Oki doki,

because of an unwanted delete action I compiled in VO :

DEFINE for := 2

which results in a "bad global name". Tried immediately the same with x#, of course :-)

>
> DEFINE @@SELF := 41 AS INT
>

very nice ;-)


regards
Karl-Heinz

Please Log in or Create an account to join the conversation.