Deutsch   English   Français   Italiano  
<vae549$1o14c$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Stephen Hoffman <seaohveh@hoffmanlabs.invalid>
Newsgroups: comp.os.vms
Subject: Re: New VSI post on Youtube
Date: Sat, 24 Aug 2024 22:32:42 -0400
Organization: HoffmanLabs LLC
Lines: 61
Message-ID: <vae549$1o14c$1@dont-email.me>
References: <vae1lj$1jrbm$1@dont-email.me> <vae3fe$1j523$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Aug 2024 04:32:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cac4f731b180842ea6705ad3cd4b7b16";
	logging-data="1836172"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19BMbYNLO65RNQRZi6ytTCRvSTzKAng/a4="
User-Agent: Unison/2.2
Cancel-Lock: sha1:THzOUnr7tAyGWygvQeE3BPyM0Lk=
Bytes: 3469

On 2024-08-25 02:04:30 +0000, Arne Vajhøj said:

> On 8/24/2024 9:33 PM, Stephen Hoffman wrote:
>> On 2024-08-20 12:36:51 +0000, Simon Clubley said:
>>> One thing I wish was available in all languages is the ability to 
>>> return multiple values from a function call so you can return both a 
>>> status and the value(s) in one assignment. Ie: "a, b, c = 
>>> demo_function(param1, param2);".
>>> 
>>> In languages with dynamic associative arrays (such as PHP), I simulate 
>>> this by returning an associative array from a function call with both 
>>> status and value fields. Makes coding _so_ much cleaner and robust.
>> 
>> For those following along at home, C supports returning a struct.
>> 
>> Languages including Swift allow returning an "optional", where you 
>> either get a value such as an object, or an indication or its absence. 
>> Swift uses the concept of "unwrapping" a result marked optional, which 
>> means you have to check before access.
>> 
>> Returning objects is more widely available, and hides a lot of this 
>> mess, as well as hiding dealing with potentially-larger data buffers. 
>> Objects and message-passing is akin to itemlist-based APIs, dragged 
>> forward a few decades.
>> 
>> In other languages, support for an optional requires explicit code, 
>> whether that might return a struct, or might return a value and a 
>> sentinel, or ilk.
> 
> I don't know Swift but I will assume Swift optional is similar to 
> optional in other languages.
> 
> It solves the return both status and value problem. But it is not a 
> general multiple return value solution. And it is really just a small 
> evolution of the traditional "return null indicate an error".

That would be a Swift function that returns an object whether optional 
or not, or a function that returns multiple values whether optional or 
not.

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/ 


The optional makes the developer's intent clear, and makes for less glue code.

There are things I don't like about Swift, not the least of which is 
being a moving target.

ObjC can return a null object, which is a somewhat different approach 
to this particular mess. Being built on C, ObjC can also return a 
struct.

Objects and message passing and the CLR and NET, etc., are all 
different approaches toward the decoupling that itemlists and related 
baggage were intended to provide.



-- 
Pure Personal Opinion | HoffmanLabs LLC