Skip to content

Reference Operator "&" RFC #323

Open

Description

@x87

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

Activity

  1. added
    type:feature
    discussion
    on Apr 24, 2024
  2. MatiDragon-YT commented on Apr 24, 2024

    @MatiDragon-YT
    Member

    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

  3. x87 commented on Apr 24, 2024

    @x87
    CollaboratorAuthor
    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

  4. MatiDragon-YT commented on Apr 25, 2024

    @MatiDragon-YT
    Member

    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

  5. x87 commented on Apr 25, 2024

    @x87
    CollaboratorAuthor
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionscope:compilertype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions