Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Operator "&" RFC #323

Open
x87 opened this issue Apr 24, 2024 · 4 comments
Open

Reference Operator "&" RFC #323

x87 opened this issue Apr 24, 2024 · 4 comments
Labels
discussion Further discussion is requested scope:compiler type:feature New feature or request

Comments

@x87
Copy link
Collaborator

x87 commented Apr 24, 2024

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
@x87 x87 added type:feature New feature or request discussion Further discussion is requested scope:compiler labels Apr 24, 2024
@MatiDragon-YT
Copy link
Member

MatiDragon-YT commented Apr 24, 2024

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
Copy link
Collaborator Author

x87 commented Apr 24, 2024

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

@MatiDragon-YT
Copy link
Member

MatiDragon-YT commented Apr 25, 2024

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
Copy link
Collaborator Author

x87 commented Apr 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Further discussion is requested scope:compiler type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants