emacs-devel
[Top][All Lists]
Advanced

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

Re: Imports / inclusion of s.el into Emacs


From: João Távora
Subject: Re: Imports / inclusion of s.el into Emacs
Date: Sun, 3 May 2020 15:13:43 +0100

On Sun, May 3, 2020 at 2:47 PM Philippe Vaucher
<address@hidden> wrote:
>
> >> split-string aliased as string-split
> >> downcase aliased as string-downcase
> >> upcase aliased as string-upcase
> >> format aliased as string-format
> >> concat aliased as string-concat
>
> >Don't do this.  Just learn these 5 names, or use apropos, as
> > has been suggested.
>
> Just curious, if these were to be introduced today, would you also name them 
> that way?

I don't know, honestly.  But that is not relevant. We are not starting
an universe from scratch.

> What possible genericity is there about downcase/upcase? Okay they work on 
> strings and on chars,
> but it's pretty clear their topic is "characters" (string) no?

Always and forever? Are strings, one-dimensional sequences of
characters by definition, the only thing you can think about that
involves characters whose case can be mutated?

> > Check out 
> > http://www.lispworks.com/documentation/HyperSpec/Body/f_stg_up.htm and 
> > http://www.lispworks.com/documentation/HyperSpec/Body/c_string.htm
>
> > Do you think this organization would be useful? What if it had a cool
> > font and some cool logos? :-)  I ask because that put me off at first, it
> > looked mouldy.)
>
> Yes, that'd be very useful and it's more or less what we are asking
> to be able to do. Again curious, do you think they made a mistake
> when they named it `string-downcase` there and not `downcase`?

It only works on strings in CL, but characters are defined to be "singleton
string designators", a common concept in CL. Maybe they couldn't
quite decide on a generic version. You see CL didn't  come from
nothing, it was a giant and very expensive effort to reconcile a
_lot_ of competing Lisps.

> >> s-truncate (len s)
> > truncate-string-to-width (I got there with apropos truncate.*string btw).
>
> Okay then let's alias that to string-truncate.

To achieve what? I would only bring confusion.  Also to the s.el
cool kids, they would be equally confused, since the arguments
are reversed.

> >> s-left (len s)
> >subseq
> >> s-right (len s)
> > Add an "from-end" arg to subseq?
>
> Why is there substring if there is subseq then?

¯\_(ツ)_/¯ History?  substring has both optional args.
Use substring if you absolutely know your sequence
is a string, subseq otherwise.

> >> s-repeat (num s)
> > (cl-loop repeat num concat s)
>
> What if I don't know cl (like I a significant number of package authors) ?

I think you might want to learn how to loop if you're going to program.
You can use while, do, etc. cl-loop is just my favourite.
I don't think this function needs to be in a library, but maybe an example
of how do this can be in one of those boring paragraphs of the manual.

> >> s-capitalize (s)
> > capitalize,  also works for chars.
> Alias it to string-capitalize :-)

I guess if I was starting from scratch I would do that.  We're not.  But maybe.

> >> s-reverse (s)
> > reverse, also works for sequences
>
> Ah, this one I didn't think worked on strings. Thought you have to split,
> reverse then join. I agree this can be left as a generic algorithm.

Good.

> >> s-contains-p (needle s &optional ignore-case)
> > string-match-p
> That can work, tho the mental path of having to do a regexp match
> while regexp-quoting the string just to do a plain text search feels very 
> inneficient.

Well, I honestly had to look up the doc if "needle" was a string
or a character.  So that mental path is quite worse for me.

> >> s-blank-p (s)
> > ugh. nil is a string?
> "is the string blank?" is a concept in many languages,
> but I understand it can be surprising at first.

Yes, things are suprising at first, then you learn them.
Get the hint? ;-)

João Távora



reply via email to

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