[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pierre Weis <Pierre.Weis@i...> |
| Subject: | Re: Negative float consts |
Hi,
> I recently found the syntax of negative float consts to be annoying.
> You have to write things like this:
>
> two_float_func 1.0 (-. 1.0)
You could also use
two_float_func 1.0 (-1.0)
> IMO, it is more pleasant to write instead:
>
> two_float_func 1.0 -1.0
>
> so I tried the following change in the lexer:
[...]
> ... and everything worked well ! I think this could be an improvement in
> the readability of numerical programs.
We abandoned this idea, since users seem to like operations without
spaces, writing
x+1
and conversely
x-1
If we had adopted negative lexems then we have a discrepancy, since
x+1 would have been an addition, while x-1 would have been an
application (interpreted as x(-1)).
In my mind, the advantages of negative lexems overcome the need of
sparse extra spaces (that we already have to add anyway, for instance
in x:=!x+1 (written x:= !x+1, to avoid the interpretation of :=! as a
single operator)). But some users argue that minimum spacing is a
well-established mathematical tradition, so that we have to avoid
mandatory extra spaces as much as possible.
If a rule had to be set, I would vote for mandatory spaces around
operators, with the benefit of negative lexems (and may be a more
liberal lexing rule for identifiers).
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis