[Gambas-user] Another syntax sweetness question and request
Jussi Lahtinen
jussi.lahtinen at gmail.com
Wed Mar 6 22:12:41 CET 2019
Why not to make object to hold the values and return it?
Jussi
On Wed, Mar 6, 2019 at 10:29 PM Tobias Boege <taboege at gmail.com> wrote:
> On Wed, 06 Mar 2019, Cedron Dawg wrote:
> > Question:
> >
> > Which is preferred: "Function .. As .." -OR- "Sub .. As .." ?
> >
> > Anybody have a strong opinion?
> >
> > I lean towards, and am using, the latter. A step away from BASIC
> perhaps, but one fewer thing a newbie has to learn. More elegant.
> >
>
> I personally use Function for pure functions, that take input and return
> a value without affecting or being affected by state of the current object.
> I use Sub for subroutines in the sense that they execute code that might
> modify state but don't necessarily return a value. So in my code you'll
> never see "Function" without "As", but you will see "Sub" with or without
> "As". What I don't use is the third synonym "Procedure". (Maybe I should
> employ that for "Sub that doesn't return a value"?)
>
> > Request:
> >
> > Would it be possible to make subs return multiple values like Python can?
> >
> > That can be really handy.
>
> I second that. Meanwhile you can emulate this through ByRef. It isn't
> pretty
> but IIRC the way ByRef is implemented could be used to make subroutines
> return multiple values. That requires a new syntax for a "tuple L-value"
> though.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190306/b851704d/attachment-0001.html>
More information about the User
mailing list