sannybuilder/dev

Reference Operator "&" RFC

Opened this issue · 4 comments

x87 commented

Given a variable var of type X, expression &var can result in the following commands:

  • if X is a Car class, &var is GET_VEHICLE_POINTER var
  • if X is a Char class, &var is GET_PED_POINTER var
  • if X is an Object class, &var is GET_OBJECT_POINTER var
  • otherwise: &var is GET_VAR_POINTER var

Given a label @label, expression &@label results in: GET_LABEL_POINTER @label

Examples:

int v
int p = &v
Car c
int pcar = &c
int plabel = &@label

The implementation of this expression can be quite complex, not only for the compiler but also for the users.
can disable constants and variables....

const a = 6@, b = &404
car a
char b
a = &a // -> 6@ = &6@  { what is that?? }
b = &b // -> &4 = &&4 { and this?? }

Is it possible to consider pasting the AND(&) symbol to the SAME(=) symbol?

const a = 6@, b = &4
car a
char b
a =& a // -> 6@ =& 6@ 
b =& b // -> &4 =& &4

In the SB documentation I did not see that this expression is reserved in something.
https://docs.sannybuilder.com/language/instructions/expressions

And reduces the time that has to be invested to add the expression.
in the case of my compiler, it is sufficient to add an opcode and express the data order

Screenshot_20240424_184010_Spck Editor

this without adding possible critical issues in this new syntax #261

x87 commented
const a = 6@, b = &404
car a
char b
a = &a // -> 6@ = &6@  { what is that?? }
b = &b // -> &4 = &&4 { and this?? }

this is not allowed in latest SB. you can't use same name for a constant and variable.

Is it possible to consider pasting the AND(&) symbol to the SAME(=) symbol?

in future it will be possible to use reference as an argument to function:

someFunc(&a)

so, no, it should be treated differently

this is not allowed in latest SB. you can't use same name for a constant and variable.

i think i am getting confused. the constant a is 6@ but &a is a variable called a and this name cannot be used, why is it already reserved in a constant? then how would it pass compiled?

wait wait, so if _actor is $_actor, then using it would also be an invalid operation?

oh my god, the new Sanny builder syntaxes make me dizzy 😵‍💫

so, no, it should be treated differently

Are you going to set up a temporary variable system that does not affect the use of local and global variables used by the script being developed?

or how will that work? can you give an example

x87 commented
const foo = 6@
car foo

you can't use same name (foo) for const and variable. you will get a compiler error. it has nothing to do with & and this proposal.

Are you going to set up a temporary variable system that does not affect the use of local and global variables used by the script being developed?

something like this, not sure what exactly yet