liberty-eiffel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Liberty-eiffel Digest, Vol 57, Issue 1


From: Hans Zwakenberg
Subject: Re: Liberty-eiffel Digest, Vol 57, Issue 1
Date: Thu, 30 Jun 2022 18:41:02 +0200 (CEST)

What would happen if neither of the two arguments in your example is void?  
Which of the two would be printed?



> liberty-eiffel-request@gnu.org hat am 30.06.2022 18:02 CEST geschrieben:
> 
>  
> Send Liberty-eiffel mailing list submissions to
>       liberty-eiffel@gnu.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>       https://lists.gnu.org/mailman/listinfo/liberty-eiffel
> or, via email, send a message with subject or body 'help' to
>       liberty-eiffel-request@gnu.org
> 
> You can reach the person managing the list at
>       liberty-eiffel-owner@gnu.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Liberty-eiffel digest..."
> 
> 
> Today's Topics:
> 
>    1. default or foo (Paolo Redælli)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 30 Jun 2022 08:14:08 +0200
> From: Paolo Redælli <paolo.redaelli@gmail.com>
> To: liberty-eiffel mailing list <liberty-eiffel@gnu.org>
> Subject: default or foo
> Message-ID: <c5e17938-d64f-de8e-b1c7-eceae2ea0ce0@gmail.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
> 
> I propose to add a feature to ANY.
> 
> infix "or" (another: like Current): like Current
> 
>      do
> 
>          if another=Void then
> 
>              Result:=Current
> 
>          else
> 
>              Result:=another
> 
>          end
> 
>      ensure Result/=Void
> 
>      end
> 
> 
> to allow writing things like
> 
>      print("a default answer" or something_that_can_be_void)
> 
> instead of
> 
>      local temp: STRING
> 
>      do
> 
>          temp := something_that_can_be_void
> 
>          if temp=Void then
> 
>              print("a default answer")
> 
>          else
> 
>              print(temp)
> 
>          end
> 
>      end
> 
> 
> Inspired by the coalescing operators. See 
> https://en.wikipedia.org/wiki/Null_coalescing_operator
> 
> Initially I thought of proposing to allow to write "foo or default" like 
> in many other languages but this would require to add to the language a 
> special case to avoid an exception for a Void call.
> 
> Using a pattern "default or foo" just avoid this.
> 
> I think it will help writing expressive yet concise code. Think of it as 
> an Eiffel-style coalescing operator.
> 
> An altertive naming would be to use a free operator but I couldn't find 
> one that I like.
> 
> 
> 
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> Liberty-eiffel mailing list
> Liberty-eiffel@gnu.org
> https://lists.gnu.org/mailman/listinfo/liberty-eiffel
> 
> 
> ------------------------------
> 
> End of Liberty-eiffel Digest, Vol 57, Issue 1
> *********************************************



reply via email to

[Prev in Thread] Current Thread [Next in Thread]