unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: Surprising behaviour of 'append' with string
       [not found] <17b9a480-cff1-212e-7d8a-894285d03646.ref@yahoo.de>
@ 2022-11-06 16:02 ` R. Diez
  2022-11-06 17:22   ` Stephen Berman
  2022-11-06 18:41   ` Emanuel Berg
  0 siblings, 2 replies; 5+ messages in thread
From: R. Diez @ 2022-11-06 16:02 UTC (permalink / raw)
  To: stephen.berman; +Cc: help-gnu-emacs


> then flatten-tree should do the job.  To also check that the elements
> are either a string or a list of strings, you could use this:
> [...]

Thanks for your help. Your routine fits the bill perfectly.


> It appears you didn't appreciate the preceding line of the doc string:
> [...]

Well, yes. Like I said, I am no Lisp expert and I get easily mislead.

Don't you think that 'append' and its documentation are not really user friendly? Its behaviour is not what you would normally expect. It doesn't make sense to join list elements with the first characters of strings. At least some example and/or warning about it would prevent unwary users like me from wasting time and feeding the general sentiment that Emacs and Lisp are not user friendly. I'm only saying this as a hint to improve the situation for other users (to improve Emacs). I am now fine myself with regards to 'append', thanks to your code.


> Isn't it better to use a shell script language then?

Whether shell is better than Lisp is debatable. But say I want to write the logic in shell. Then I would need to pass the information (flags and config settings) down from Emacs (where they live now), in form of command-line arguments, and that's the kind of routine I am looking for in order to help me do that, isn't it?


Regards,
   rdiez



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Surprising behaviour of 'append' with string
  2022-11-06 16:02 ` Surprising behaviour of 'append' with string R. Diez
@ 2022-11-06 17:22   ` Stephen Berman
  2022-11-06 18:41   ` Emanuel Berg
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Berman @ 2022-11-06 17:22 UTC (permalink / raw)
  To: R. Diez; +Cc: help-gnu-emacs

On Sun, 6 Nov 2022 17:02:48 +0100 "R. Diez" <rdiezmail-emacs@yahoo.de> wrote:

>> then flatten-tree should do the job.  To also check that the elements
>> are either a string or a list of strings, you could use this:
>> [...]
>
> Thanks for your help. Your routine fits the bill perfectly.

Glad it helped.

> Don't you think that 'append' and its documentation are not really
> user friendly? Its behaviour is not what you would normally expect. It
> doesn't make sense to join list elements with the first characters of
> strings.

`append' operates not just on lists but also vectors and strings.  And
with the latter it's not just the first characters that are appended:

(append "this" "is" "a" "test")
=> (116 104 105 115 105 115 97 . "test")
     t   h   i   s   i   s  a

Each element of each sequence -- in this case each character of each
string -- is appended -- except for the last string, which, as the doc
string says "is just used as the tail of the new list".

> At least some example and/or warning about it would prevent unwary
> users like me from wasting time and feeding the general sentiment that
> Emacs and Lisp are not user friendly. I'm only saying this as a hint
> to improve the situation for other users (to improve Emacs). I am now
> fine myself with regards to 'append', thanks to your code.

There are examples in the Emacs Lisp manual.  Perhaps you are familiar
with an append function and string data type in another programming
language and assumed they work the same way in Emacs Lisp.  Consulting
the manual may help further.

Steve Berman



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Surprising behaviour of 'append' with string
  2022-11-06 16:02 ` Surprising behaviour of 'append' with string R. Diez
  2022-11-06 17:22   ` Stephen Berman
@ 2022-11-06 18:41   ` Emanuel Berg
  2022-11-07 18:05     ` Michael Heerdegen
  1 sibling, 1 reply; 5+ messages in thread
From: Emanuel Berg @ 2022-11-06 18:41 UTC (permalink / raw)
  To: help-gnu-emacs

R Diez wrote:

> Don't you think that 'append' and its documentation are not
> really user friendly? Its behaviour is not what you would
> normally expect. It doesn't make sense to join list elements
> with the first characters of strings.

Well, to the person who wrote it it did, but I don't know what
use case he had in mind.

> At least some example and/or warning about it would prevent
> unwary users

Sure, you can use `report-emacs-bug' for this.

> from wasting time and feeding the general sentiment that
> Emacs and Lisp are not user friendly.

Emacs and Lisp are maximalist systems that grow from
everywhere, at the same time, and always, such systems can be
perceived as chaotic to people who are not used to that
approach, which actually isn't that unusual, but such systems
are also more interesting and ultimately more powerful.

Also that power, in the sense there are several ways to do
things and everything is configurable thru the same interface
(Elisp and now to some extent C, with dynamic modules, even),
all that maybe doesn't feel user friendly but at the end of
the day it's a true pal.

>> Isn't it better to use a shell script language then?
>
> Whether shell is better than Lisp is debatable. But say I want
> to write the logic in shell. Then I would need to pass the
> information (flags and config settings) down from Emacs (where
> they live now), in form of command-line arguments, and that's
> the kind of routine I am looking for in order to help me do
> that, isn't it?

Shell script languages and Lisp are not really comparable,
script languages are useful for user-interaction when the user
uses the shell, also when a lot of shell tools and/or other
scripts are involved. Lisp OTOH is a general-purpose
programming language.

So while you can ask a script for some data from a Lisp
program, to use Lisp to put together shell commands to be
executed - that will only complicate things for no gain in
sight, it's not optimized for that, and why would it be?
The shell script languages are, or should be, or it's better
than doing it in Lisp anyway.

Note that there are Lisp shell languages as well! Lish (Lisp
as a shell) [1] - Lush (Lisp Universal Shell) [2] and
many other. However if you use Emacs you already have Lisp
(Emacs Lisp or Elisp) so I'd actually recommend doing the
shell in some POSIX-style extended shell, e.g. bash, ksh or
zsh ...

[1] https://www.cliki.net/Lisp%20as%20a%20shell
[2] https://lush.sourceforge.net/

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Surprising behaviour of 'append' with string
  2022-11-06 18:41   ` Emanuel Berg
@ 2022-11-07 18:05     ` Michael Heerdegen
  2022-11-07 18:35       ` Emanuel Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2022-11-07 18:05 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <incal@dataswamp.org> writes:

> > At least some example and/or warning about it would prevent
> > unwary users
>
> Sure, you can use `report-emacs-bug' for this.

We normally don't warn about uses of documented behavior.

Michael.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Surprising behaviour of 'append' with string
  2022-11-07 18:05     ` Michael Heerdegen
@ 2022-11-07 18:35       ` Emanuel Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2022-11-07 18:35 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

>>> At least some example and/or warning about it would
>>> prevent unwary users [...]
>>
>> Sure, you can use `report-emacs-bug' for this.
>
> We normally don't warn about uses of documented behavior.

I mean as a channel if the OP was unhappy with the current
docstring for him to provide a suggestion how to improve
it ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-07 18:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <17b9a480-cff1-212e-7d8a-894285d03646.ref@yahoo.de>
2022-11-06 16:02 ` Surprising behaviour of 'append' with string R. Diez
2022-11-06 17:22   ` Stephen Berman
2022-11-06 18:41   ` Emanuel Berg
2022-11-07 18:05     ` Michael Heerdegen
2022-11-07 18:35       ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).