SRL Archive - Help

Define something as something else..


Brandon

2011-07-08 22:47:44

How do I define something as another thing..

Example:

Define Not as !.. So instead of typing if not function.. I can type if !function..

or Define Begin as { and End as }.. or even Define "and" as &&;

How do I do this?


[LEFT]I tried: [COLOR=#0000FF][B]//LOLOL fail bad..[/B][/COLOR]
[COLOR=#0000FF][B]{$ifdef !}[/B][/COLOR]
! = [COLOR=#000000][B]Not[/B][/COLOR];
[COLOR=#0000FF][B]{$endif}[/B][/COLOR]
[/LEFT]

Harry

2011-07-08 22:54:38

wat

Can you explain using examples from another well-established programming language? I don't know what you're trying to do.

Brandon

2011-07-08 23:01:36

Example in C++:

#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));
That redefines the do while loop into a Repeat Until loop.. same thing really just different words..
Basically instead of typing:

do{
//Stuff here
}while(! condition here);

//I can type
Repeat
//stuff here
Until(condition here);
Well I want to redefine Begin, end, Not, And.. so that I can type {, }, !, &&..

So instead of typing:

  
[LEFT][COLOR=#000000][B]Begin[/B][/COLOR]
[COLOR=#0000FF][B]//Stuff here[/B][/COLOR]
[COLOR=#000000][B]End[/B][/COLOR];
[/LEFT]
[LEFT]
[/LEFT]
I would type:
{
//Stuff here
}

KingKong

2011-07-08 23:47:40

AFAIK thats not possible because then you'd be changing reserved words in the language.

Narcle

2011-07-09 05:54:40

You could probably make a script converter. Code it in that language then run a convert script and it would replace those and run.

mat_de_b

2011-07-09 07:12:44

I think what Narcle said is the easiest route. It would also make it easier for everyone to read the script after you've made it.

TomTuff

2011-07-13 20:56:11

Are you looking for {$IFNDEF}?

E: Nevermind lol.

Echo_

2011-07-14 04:05:45

The only problem with using a convert script is that in the end he won't be able to run it in Simba.

Dgby714

2011-07-14 04:14:36

It could prob be added, tho it is not currently a feature of Simba.

Basicly we would need to add a compiler directive like so.
{$R a(...) b(...)}

and the Preprocesser will replace all occurrences of a() with b() before compiling.