Structs can't be passed as reference.

About Monkey 2 Forums Monkey 2 Programming Help Structs can't be passed as reference.

This topic contains 3 replies, has 3 voices, and was last updated by  cocon 2 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3217

    cocon
    Participant

    It looks like structs can’t be passed as reference, is it possible?

    #3236

    Mark Sibly
    Keymaster

    In general, no.

    You can Varptr a struct use a pointer, but this is very unsafe.

    #5399

    arpie
    Participant

    Mark, would you mind quickly clarifying why this would be very unsafe?  Is it for the usual reasons that pointers are unsafe or is there something more dangerous about Varptr and Ptr in Monkey?

    #5455

    cocon
    Participant

    The catch here is when you want to use a library written in C through a module, you might use pointers to call the C API (for example the OpenGL API), personally I would no find something odd about this approach.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.