Re: Reintroducing fish, the friendly interactive shell




Stephane CHAZELAS skrev:

2006-03-6, 20:16(-08), liljencrantz@xxxxxxxxx:
[...]
Than you for your kind words. I'd say that many of the extensions
provided over the years have been implemented in rather inconsistent
ways. If functions, indirect variable expansion, arrays, local
variables and other new features had been better integrated into the
shell, the language would, in my opinion, have been in a much better
condition today.

I couldn't agree more.

Glad to hear we agree here. So, aside from the 'FOO=BAR echo
$FOO'-question, where we seem to see things differently, what are your
feelings on e.g. the fish array syntax?


[...]
This is completely untrue. Although the explanation is beyond
the scope of the discussion (and our patience...), the grouping
keyword ("}") is commensurate with the other terminating
keywords "esac", "done", and "fi", and as such require being on
their own line or after another keyword.

If I understand you correctly, your point is that '}' should be viewed
as a command-like keyword, like 'esac' and 'fi'. And if you do so, it
will indeed seem more intuitive. But that is beside the point for me,
since one would not expect '}' to behave that way because:

* The syntax is clearly borrowed/inspired by from C-like languages
where } does not behave like a function or reserved word.
[...]

That could be a backward portability issue.

echo }

outputs "}" (it's not the case in zsh except in sh/ksh modes).

As you mentioned in another post, zsh is much more clever in it's
parsing of ';' and '}'. It may be that there are some awkward edge
cases where there is a clash between braces used to denote blocks and
braces used fo brace expansion, but overall the zsh syntax makes _much_
more sense to me. That said, there is of course still the issue of
using all these keywords for denoting end-of-block:

fi, esac, done, }, ;;

When testing around in zsh, the only thing that I felt should be
allowed which wasn't was the use of multiple ';' without any whitespace
between them. It seems that ';;' is interpreted as the case-end
keyword, and as such will lead to a parse error. That means that one
can legally write an empty command like this:

;

But one can't write two empty commands on a single line like this:

;;

which is of course a very minor detail all things considered. I mention
this mostly since I think that it makes a lot of sense from a language
point of view to minimize the difference between a ';' and a newline.
It is legal to have any number of newlines with no whitespace, so from
that perspective it makes sense to do the same with ';'. This is an
exact parallel to how spaces, tabs and newlines are exactly equivalent
outside of string literals in C. In fish ';' and newlines are
syntactically equivalent in none-quoted contexts, so you can write
';;;;;;;;;' and fish will gladly do nothing at all.


--
Stéphane

--
Axel

.



Relevant Pages

  • Re: Static Read-only array fields in C++
    ... this appears only to be a problem relating to managed ... the 'const' keyword in the ... > If not using arrays, does the 'const' keyword actually result in the ...
    (microsoft.public.dotnet.languages.vc)
  • Why it is impossible?
    ... FileSearch object in Word 2003 macro. ... contain at least two keyword, ... If TotalFiles = 0 Then ... arrays which present in every array, modelling in this way logical "AND". ...
    (microsoft.public.word.vba.general)
  • Re: NullPointerException
    ... Do not use the keyword 'null' ... Make all fields final to force compile error for non-initialisation. ... Do not use the new Typesyntax for creating arrays of objects ...
    (comp.lang.java.programmer)
  • Re: C Programming Assignment:
    ... > string is a keyword or identifier within C itself. ... Return NULL if you run to the end of the line without reading an identifier, ... > do i initialise a linked list to compare the two arrays or what? ...
    (comp.lang.c)
  • Re: help directory name issue...
    ... I can list the keyword, file name and directory name with path name, ... output myfiles and outputs directory names ... and if you want sentences you could possibly split on punctuation ... instead of newlines. ...
    (comp.lang.ruby)