out idea

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

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

    dmaz
    Participant

    I’d love to see multiple return vars supported… how about a language semantic where we enclose them in parens on the left side?

    (key:int,value:myclass) = somefunctiongetstuff(map);

    this would translate to something like

    int key;
    myclass value;
    somefunctiongetstuff(map,&key,value)

    ??

    #276

    Mark Sibly
    Keymaster

    Wont be happening in the near future, if ever.

    Support for ‘tuples’ would likely involve major changes to the compiler, and given I’ve never really used them or even felt the need for them (perhaps very infrequently…) they’re just not really in the picture for me right now.

    What *may* be happening is bmx style ‘var’ parameters (or ‘out’ params in c# lingo) which would achieve something similar.

    This is a way off yet (probably look into it when doing reflection) but my vague plan here is to mirror the super-flexible function pointer mechanism with a similar ‘variable pointer’ system that can be used to create pointers to fields/properties/globals. Maybe!

     

    #278

    dmaz
    Participant

    I wasn’t thinking real tuples, just thinking about faking them…  I was under the impression that since the compiler is mostly a translator(?), crazy semantics become far more doable.

    I was thinking was under the hood the compiler would just create out parameters to make this all work… just throwing stuff out there, no worries.

    but yeah, they are just a cool convenience thing to make code shorter and more readable.

    I’ve found the best way to keep code simple is to remove most of it.  😀

    #279

    Mark Sibly
    Keymaster

    > crazy semantics become far more doable.

    Not really – the ‘front end’ (ie: parsing, type checking etc) is pretty much the same as a real compiler’s. Only the back end is simplified, and that doesn’t have to deal with syntax at all, as all that stuff is out of the way.

    To support this, in addition to the above, the return statement would need to change, the compiler would have to be able to ‘unpack’ values so func1( func2() ) could work, a new ‘type’ would need to be added etc, at which point you’re effectively implementing tuples!

     

     

     

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

You must be logged in to reply to this topic.