realbasic-betas.mbox
[Top] [All Lists]

Re: Ability to have more then one Return Value

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: Ability to have more then one Return Value
From: Geoff Canyon <gcanyon at inspiredlogic dot com>
Date: Sun, 28 Jul 2002 08:34:49 -0700
At 12:18 PM -0500 7/27/02, Nathan Fisher wrote:
>On a somewhat similar note, it would be nice for functions to be able to 
>return more than one value.  This would require a bit of a change to the 
>compiler's syntax, but would eliminate the need for "wrapper classes" in a lot 
>of instances.
>
>For example, right now I might call GetAddressAndPort(Server) to get the 
>server's address and port.  As it is now, I would probably have to return it 
>as a single string, like "192.168.1.15:110" and nthfield out the results.  
>This would be so much handier:
>
>     Sub GetAddressAndPort(Server as string) as string,integer
>or
>     Sub GetAddressAndPort(Server as string) as string, as integer
>
>and call it like
>
>     Address, Port=GetAddressAndPort(Server)
>
>Does something like this have a prayer of being implemented?  As far as I can 
>tell, it doesn't break existing syntax.

Wouldn't it be fairly simple (and not require any modification to RB) to 
instead implement something like:

     Sub GetAddressAndPort(Server as string) as string

and call it like this:

     AddressAndPort=GetAddressAndPort(Server)

and then just find the offset of the comma in the returned result and split it 
appropriately into an address and port?
-- 

regards,

Geoff Canyon
gcanyon at inspiredlogic dot com


<Prev in Thread] Current Thread [Next in Thread>