Log in

View Full Version : Define something as something else..



Brandon
07-09-2011, 02:47 AM
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?




I tried: //LOLOL fail bad..
{$ifdef !}
! = Not;
{$endif}

Harry
07-09-2011, 02:54 AM
wat

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

Brandon
07-09-2011, 03:01 AM
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:




Begin
//Stuff here
End;




I would type:

{
//Stuff here
}

KingKong
07-09-2011, 03:47 AM
AFAIK thats not possible because then you'd be changing reserved words in the language.

Narcle
07-09-2011, 09:54 AM
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
07-09-2011, 11:12 AM
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
07-14-2011, 12:56 AM
Are you looking for {$IFNDEF}?

E: Nevermind lol.

Echo_
07-14-2011, 08:05 AM
The only problem with using a convert script is that in the end he won't be able to run it in Simba.

Dgby714
07-14-2011, 08:14 AM
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.