Version française
Home     About     Download     Resources     Contact us    
Browse thread
let int = ?([' ' '\t'] '-') digits+
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pal-Kristian Engstad <pal_engstad@n...>
Subject: Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+
I think you all misunderstand his proposal. He wants:

q - 1 => Add(q, -1)
q -1 => Apply(q, -1)
q-1 => Add(q, -1)

In other words, a space followed by a negative, followed by a number is 
to be parsed as a number.

PKE.

skaller wrote:
> On Fri, 2007-06-29 at 16:39 +0100, Jon Harrop wrote:
>   
>> If OCaml's lexer handled numbers of this format, would it be possible to 
>> write:
>>
>>   f -1 -2
>>
>> to mean:
>>
>>   f (-1) (-2)
>>
>> rather than:
>>
>>   f - 1 - 2
>>
>> Is this a good idea?
>>     
>
> No, I don't think so, because
>
> 	-1
>
> and
>
> 	- 1
>
> would then be distinct, and there's be confusion with:
>
> 	x-1
>
> which would actually mean
>
> 	x (-1)
>
> rather than
>
> 	x - 1
>
> That would break reams of code .. ;(
>
>   

-- 
Pål-Kristian Engstad (engstad@naughtydog.com), Lead Graphics & Engine Programmer,  
"Uncharted"-team, Naughty Dog, Inc., 1601 Cloverfield Blvd, 6000 North,
Santa Monica, CA 90404, USA. Ph.: (310) 633-9112.

"Most of us would do well to remember that there is a reason Carmack
is Carmack, and we are not Carmack.",
                       Jonathan Blow, 2/1/2006, GD Algo Mailing List