* let int = ?([' ' '\t'] '-') digits+ @ 2007-06-29 15:39 Jon Harrop 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer ` (3 more replies) 0 siblings, 4 replies; 14+ messages in thread From: Jon Harrop @ 2007-06-29 15:39 UTC (permalink / raw) To: Caml List 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? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:39 let int = ?([' ' '\t'] '-') digits+ Jon Harrop @ 2007-06-29 15:56 ` Robert C Fischer 2007-06-29 16:32 ` Brian Hurt 2007-06-29 16:40 ` Jon Harrop 2007-06-29 15:57 ` pzimmer ` (2 subsequent siblings) 3 siblings, 2 replies; 14+ messages in thread From: Robert C Fischer @ 2007-06-29 15:56 UTC (permalink / raw) To: Caml List How would I write f - 1 to mean "one less than the value of f"? ~~ Robert. 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? > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer @ 2007-06-29 16:32 ` Brian Hurt 2007-06-29 16:40 ` Jon Harrop 1 sibling, 0 replies; 14+ messages in thread From: Brian Hurt @ 2007-06-29 16:32 UTC (permalink / raw) To: Caml List Robert C Fischer wrote: > How would I write f - 1 to mean "one less than the value of f"? In this proposal, you'd write f - 1, with the space between the - and the 1 being important. That said, the next complaint will be that Ocaml "misinterprets" f -x as ( - ) f x, and not the "obviously correct" f (-x). Brian ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer 2007-06-29 16:32 ` Brian Hurt @ 2007-06-29 16:40 ` Jon Harrop 2007-06-29 18:21 ` Philippe Wang 1 sibling, 1 reply; 14+ messages in thread From: Jon Harrop @ 2007-06-29 16:40 UTC (permalink / raw) To: Caml List On Friday 29 June 2007 16:56:45 Robert C Fischer wrote: > How would I write f - 1 to mean "one less than the value of f"? As: f - 1 The space before the digit means that it will not match this regexp. Or: f-1 The lack of a space before the "-" means that it will not match this regexp. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 16:40 ` Jon Harrop @ 2007-06-29 18:21 ` Philippe Wang 0 siblings, 0 replies; 14+ messages in thread From: Philippe Wang @ 2007-06-29 18:21 UTC (permalink / raw) To: Jon Harrop, ocaml ml Jon Harrop wrote: > On Friday 29 June 2007 16:56:45 Robert C Fischer wrote: > >> How would I write f - 1 to mean "one less than the value of f"? >> > > As: > > f - 1 > > The space before the digit means that it will not match this regexp. > > Or: > > f-1 > > The lack of a space before the "-" means that it will not match this regexp. I think it's quite too hard to explain, and it leads you to make mistakes too easily. By the way, I wonder how you could explain that to students learning the language... What I think is that : - whether they know nothing about programming : then they end up thinking it's quite too ugly... - whether they already know something about programming : they would think that the language is ugly and stick to those they already know... Anyways, I really wouldn't want that. One should not have to spend ten years to learn a programming language, just because of such tricks. -- Philippe Wang mail[at]philippewang.info ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:39 let int = ?([' ' '\t'] '-') digits+ Jon Harrop 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer @ 2007-06-29 15:57 ` pzimmer 2007-06-29 16:35 ` Robert C Fischer 2007-06-29 16:41 ` Jon Harrop 2007-06-29 17:57 ` Stefan Monnier 2007-06-29 18:29 ` [Caml-list] " skaller 3 siblings, 2 replies; 14+ messages in thread From: pzimmer @ 2007-06-29 15:57 UTC (permalink / raw) To: Caml List Do you really want x-3*7 to be interpreted as (x (-3)) * 7 ? 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? > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:57 ` pzimmer @ 2007-06-29 16:35 ` Robert C Fischer 2007-06-29 16:41 ` Jon Harrop 1 sibling, 0 replies; 14+ messages in thread From: Robert C Fischer @ 2007-06-29 16:35 UTC (permalink / raw) To: Caml List This got filtered out, I think, so I'm trying again: How would one express "one less than the value returned by function f" if f -1 was treated as f(-1)? ~~ Robert. pzimmer@janestcapital.com wrote: > Do you really want > > x-3*7 > > to be interpreted as > > (x (-3)) * 7 > > ? > > > 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? >> >> > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:57 ` pzimmer 2007-06-29 16:35 ` Robert C Fischer @ 2007-06-29 16:41 ` Jon Harrop 1 sibling, 0 replies; 14+ messages in thread From: Jon Harrop @ 2007-06-29 16:41 UTC (permalink / raw) To: caml-list On Friday 29 June 2007 16:57:26 pzimmer@janestcapital.com wrote: > Do you really want > > x-3*7 > > to be interpreted as > > (x (-3)) * 7 Unless I am mistaken, that would not match this regexp (there is no space before the "-") so it would be lexed and parsed conventionally. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:39 let int = ?([' ' '\t'] '-') digits+ Jon Harrop 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer 2007-06-29 15:57 ` pzimmer @ 2007-06-29 17:57 ` Stefan Monnier 2007-06-29 18:11 ` [Caml-list] " Robert C Fischer 2007-06-29 18:29 ` [Caml-list] " skaller 3 siblings, 1 reply; 14+ messages in thread From: Stefan Monnier @ 2007-06-29 17:57 UTC (permalink / raw) To: caml-list > Is this a good idea? Don't think so: it doesn't help the case where you want to use negation on a variable rather than a constant, so it introduces a fairly subtle inconsistency which doesn't seem to be worth the trouble. I guess in Haskell you could use type class trickery so that "f - 3" substracts 3 from f if f is numeric and passes -3 to f if f is a function (I leave the case where f is both a function and a member of the Number class as an exercise to the user). that would be even more evil, Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] Re: let int = ?([' ' '\t'] '-') digits+ 2007-06-29 17:57 ` Stefan Monnier @ 2007-06-29 18:11 ` Robert C Fischer 2007-06-29 21:05 ` Jon Harrop 0 siblings, 1 reply; 14+ messages in thread From: Robert C Fischer @ 2007-06-29 18:11 UTC (permalink / raw) To: caml-list Syntax polymorphism violates the principle of least surprise. It is, indeed, Teh Eevil. ~~ Robert. Stefan Monnier wrote: >> Is this a good idea? >> > > Don't think so: it doesn't help the case where you want to use negation on > a variable rather than a constant, so it introduces a fairly > subtle inconsistency which doesn't seem to be worth the trouble. > > I guess in Haskell you could use type class trickery so that > > "f - 3" substracts 3 from f if f is numeric and passes -3 to f if f is > a function (I leave the case where f is both a function and a member of > the Number class as an exercise to the user). > > that would be even more evil, > > > Stefan > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] Re: let int = ?([' ' '\t'] '-') digits+ 2007-06-29 18:11 ` [Caml-list] " Robert C Fischer @ 2007-06-29 21:05 ` Jon Harrop 0 siblings, 0 replies; 14+ messages in thread From: Jon Harrop @ 2007-06-29 21:05 UTC (permalink / raw) To: caml-list, robert.fischer On Friday 29 June 2007 19:11:23 Robert C Fischer wrote: > Syntax polymorphism violates the principle of least surprise. It is, > indeed, Teh Eevil. The designers of OCaml clearly disagreed when they went out of their way to remove superfluous parentheses: [1, 2] I am taking the idea further, AFAICT. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 15:39 let int = ?([' ' '\t'] '-') digits+ Jon Harrop ` (2 preceding siblings ...) 2007-06-29 17:57 ` Stefan Monnier @ 2007-06-29 18:29 ` skaller 2007-06-29 18:53 ` Pal-Kristian Engstad 3 siblings, 1 reply; 14+ messages in thread From: skaller @ 2007-06-29 18:29 UTC (permalink / raw) To: Jon Harrop; +Cc: Caml List 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 .. ;( -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 18:29 ` [Caml-list] " skaller @ 2007-06-29 18:53 ` Pal-Kristian Engstad 2007-06-29 19:21 ` Daniel Bünzli 0 siblings, 1 reply; 14+ messages in thread From: Pal-Kristian Engstad @ 2007-06-29 18:53 UTC (permalink / raw) To: skaller; +Cc: caml-list 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Caml-list] let int = ?([' ' '\t'] '-') digits+ 2007-06-29 18:53 ` Pal-Kristian Engstad @ 2007-06-29 19:21 ` Daniel Bünzli 0 siblings, 0 replies; 14+ messages in thread From: Daniel Bünzli @ 2007-06-29 19:21 UTC (permalink / raw) To: caml-list Le 29 juin 07 à 20:53, Pal-Kristian Engstad a écrit : > I think you all misunderstand his proposal. He wants: > > q - 1 => Add(q, -1) > q -1 => Apply(q, -1) > q-1 => Add(q, -1) However we all understood it's a bad idea. Daniel ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-06-29 21:11 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-06-29 15:39 let int = ?([' ' '\t'] '-') digits+ Jon Harrop 2007-06-29 15:56 ` [Caml-list] " Robert C Fischer 2007-06-29 16:32 ` Brian Hurt 2007-06-29 16:40 ` Jon Harrop 2007-06-29 18:21 ` Philippe Wang 2007-06-29 15:57 ` pzimmer 2007-06-29 16:35 ` Robert C Fischer 2007-06-29 16:41 ` Jon Harrop 2007-06-29 17:57 ` Stefan Monnier 2007-06-29 18:11 ` [Caml-list] " Robert C Fischer 2007-06-29 21:05 ` Jon Harrop 2007-06-29 18:29 ` [Caml-list] " skaller 2007-06-29 18:53 ` Pal-Kristian Engstad 2007-06-29 19:21 ` Daniel Bünzli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox