liberty-eiffel
[Top][All Lists]
Advanced

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

Re: Infix "*" in ABSTRACT_STRING


From: Paolo Redaelli
Subject: Re: Infix "*" in ABSTRACT_STRING
Date: Sun, 31 Dec 2023 11:37:03 +0100
User-agent: Mozilla Thunderbird


Il 30/12/23 13:19, Eric Bezault ha scritto:
On 30/12/2023 10:36, Patrick Cloarec wrote:
It is unnatural to me to define a binary operator as the feature of the class of one object. infix is the less intuitive construction offered by Eiffel, in my humble opinion.

They are available in one way or another in many
other languages. For example, in Python:

>>> "Ho "*3+"! Merry Christmas"
'Ho Ho Ho ! Merry Christmas'

I forgot to express my pleasant surprise on discovering you registered here.

It is not at all obvious nor expected, but very, very wellcome.

Having said that I think that this simple desire raise a legit issue about the expressiveness of Eiffel. I am also convinced that Raphael is right, such a "beautiful" feature shall not be in STRING nor in INTEGER.

Name it repeated infix "*" alias "×"

it seems to me that it actually belongs to

STRING is a NATIVELY_STORED_STRING which is an ABSTRACT_STRING that inherits: COMPARABLE, HASHABLE, SEARCHABLE, STORABLE, TRAVERSABLE

The more general the class where we put "repeated" the better.

But this also raise another question: why STRING is not a COLLECTION[CHARACTER]? 

Because def __mul__ in Python works also on lists and tuples... at a first glance it seems that this is a feature belonging to TRAVERSABLE or to INDEXABLE.

Let's say what can we see in FreeELKS (https://www.eiffel.org/files/doc/static/23.09/libraries/base/index.html BTW, it is quite convoluted to come here from eiffel.org...): neither STRING_32 or STRING_8 offer a feature like repeated (but it offers nice operators such as three_way_comparison alias "" 🙂); they are INDEXABLE.

COLLECTION, a CONTAINER that has fill (other: CONTAINER [G]) that Fill the container with as many other items of other as possible.

So, as far as I can say both STRING and COLLECTION, both Liberty of FreeELKS are INDEXABLE. 

Does "repeated" query really belongs here?

Lastly, I want to reassure Raphael: no, I do not want to put this into curtiss! 

(but I would put alias "[]"  alongside item where meaningful)


reply via email to

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