You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've played around with a way to 'define' objects, defined objects are copied each place they are used. This means that they are extremely similar to #define in C/C++ (that's why I'm calling the definitions).
My current syntax is;
a : T=b// Or to infera :=b// No support for this however since I don't see a needa : T// And function calls are fine however see the bottom notea :=B.x()
Where b can be any value such as an array, map, or integral type same as if you were passing an argument into a function. The type is a 'unique' thing since so far no types have really been used except in IR, I would propose either follow the IR type names (int, flt, str, bool, obj, dec) with support for arrays/maps like how you define 'object' maps/arrays i.e. x : [int : []flt] = { 3 : [1.0, 2.5], 5 : [5.3, 3.9] }
We could also expand the names to be like int, float, string, bool, object, decimal
NOTE: function calls
Function calls are a small problem because of the following reason;
Should we cache the value of the call at the site of definition and copy that to each call
Now we may want to do this because of something like this;
A : BA.x=2val :=A.xA.z=val// clearly 2A.x=5// is val 2 or 5?A.y=val// should this be 2 or 5?
Now originally I would say it would be '2', however by the idea of definitions it would become A.y = A.x which would be 5.
Maybe we support this but also support 'references' which would emulate the second behaviour i.e. 5. This could be done through defining the reference like val := &A.x. This is actually easier to implement as it would just make each x = val into x = A.x instead, where as if you go the value without the & then we would need to make a 'copy' somewhere to use later on, perhaps we could implement this by placing the 'val' as a register (which typically just holds objects but I don't see how it can't hold a non object), which can be indexed as usual by a pushobj (which would push an object from a register onto the stack), this IR probably needs to be implemented anyways but this would require it.
The text was updated successfully, but these errors were encountered:
I've played around with a way to 'define' objects, defined objects are copied each place they are used. This means that they are extremely similar to
#define
in C/C++ (that's why I'm calling the definitions).My current syntax is;
Where
b
can be any value such as an array, map, or integral type same as if you were passing an argument into a function. The type is a 'unique' thing since so far no types have really been used except in IR, I would propose either follow the IR type names (int
,flt
,str
,bool
,obj
,dec
) with support for arrays/maps like how you define 'object' maps/arrays i.e.x : [int : []flt] = { 3 : [1.0, 2.5], 5 : [5.3, 3.9] }
We could also expand the names to be like
int
,float
,string
,bool
,object
,decimal
NOTE: function calls
Function calls are a small problem because of the following reason;
Now we may want to do this because of something like this;
Now originally I would say it would be '2', however by the idea of definitions it would become
A.y = A.x
which would be5
.Maybe we support this but also support 'references' which would emulate the second behaviour i.e. 5. This could be done through defining the reference like
val := &A.x
. This is actually easier to implement as it would just make eachx = val
intox = A.x
instead, where as if you go the value without the&
then we would need to make a 'copy' somewhere to use later on, perhaps we could implement this by placing the 'val' as a register (which typically just holds objects but I don't see how it can't hold a non object), which can be indexed as usual by apushobj
(which would push an object from a register onto the stack), this IR probably needs to be implemented anyways but this would require it.The text was updated successfully, but these errors were encountered: