[Gambas-user] Another syntax sweetness question and request

Cedron Dawg cedron at exede.net
Wed Mar 6 22:28:41 CET 2019


For syntax, the Python model is good:

>From the caller:        a, b, c = FindComplicatedValues( w, x, y, z )
        
In the sub:             return a, b ,c              

        
I think it is conceputally better to think of the calling arguments as a "send" to the sub and the return arguments as a "recv".  In my prefixing, I use, "arg" for a value this is passed, and "ret" for a value that is expected to be updated.  The problem is without that, which is merely a convention, a user may not know, pass a value to a sub and have it updated without realizing that that would happen.  Those can be hard bugs to find.



Since you have bytecode interpreter, you can mess with the "processor architecture" if you want to.

Not sure how either you or Python does it, but it can go something like this:

On the call:

   push arguments on the stack
   push references to return values
   push the instruction pointer

In the sub:

    all data access on the return values is done by the reference from the stack
    (that part of the frame is read-only)
   
On the return:

    pop the instruction pointer 
    be on your merry way    
    
I'm wanting to see Gambas crush Python.  I like Python a lot better than C/Java or any of the scripters, but the lack of hard typing, and the use of enforced indentation to save control structure terminators is a little distasteful to me.



----- Original Message -----
From: "Benoît Minisini" <g4mba5 at gmail.com>
You can use "ByRef" to return several values to the caller.

I don't think I would find a good syntax for returning several values, 
nor a good implementation for that. Moreover I find that very difficult 
to read.

Regards,

-- 
Benoît Minisini

----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----


More information about the User mailing list