Compiler - Macros/Directives etc... IDEA

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
HarryO
User
User
Posts: 42
Joined: Wed May 07, 2003 4:25 am
Location: Palatine,IL.,USA

Compiler - Macros/Directives etc... IDEA

Post by HarryO »

I have been reading the posts related to compile time capabilities.

I have an idea (WARNING!!! NOT FULLY THOUGHT OUT)

Observation:

Most (if not all) of the request are really aimed towards being able
to manipulate/change information at the point-in-time the source code
gets compiled.

Currently, Constants use the '#' notation (token).

While the existing compiler directives are treated as seperate tokens.

This token now means "Evalute expression at compile time only".

Suggestion:

Why not use the same token (#) to mean that any expression which
follows is to be evalutated only at compile time. For example:

;
;- Constants
;
;Existing capabilities

#Start = 0
#Var_1 = #Start : #Start = #Start + 1
#Var_2 = #Start : #Start = #Start + 1

; New capabilities
#Char_Pos.w = 1
#Char_1.b = #Mid(#String(#PB_Compiler_Date,#Char_Pos,1))
#Char_pos = #Char_Pos = #Char_pos + 1
#Char_2.b = #Mid(#String(#PB_Compiler_Date,#Char_Pos,1))
#Char_pos = #Char_Pos = #Char_pos + 1

This would allow the use of any (Most??) of the commands to act as
a compiler directive/macro language.

OK, FLAME SUIT ON!!! What does everyone think of this?

HarryO
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

this can be only be done on specific command such as chr() and only
with constant ,if i am not wrong #contant = chr(20) : debug #constant allready works.
since char(i) it is dynamically calculated on runtime ,and this is correct way,
cannot be done.
may be some more command should be added such as Asc() and more
i think its allready discussed sometime anyway
Christos
Post Reply