* [Caml-list] raise extra arg ignored @ 2001-10-27 19:51 Pixel 2001-10-27 20:30 ` Daniel de Rauglaudre 2001-10-29 10:26 ` Xavier Leroy 0 siblings, 2 replies; 11+ messages in thread From: Pixel @ 2001-10-27 19:51 UTC (permalink / raw) To: caml-list failwith "foo" "bar" failwith "foo" are equivalent. exception Foo;; raise Foo 1 raise Foo same for this. I understand why it typechecks, but couldn't there be a special check for this since it can't be useful (or can it??) -- Pixel ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-27 19:51 [Caml-list] raise extra arg ignored Pixel @ 2001-10-27 20:30 ` Daniel de Rauglaudre 2001-10-27 23:44 ` Pixel 2001-10-28 19:47 ` Nicolas George 2001-10-29 10:26 ` Xavier Leroy 1 sibling, 2 replies; 11+ messages in thread From: Daniel de Rauglaudre @ 2001-10-27 20:30 UTC (permalink / raw) To: caml-list Hi, On Sat, Oct 27, 2001 at 09:51:05PM +0200, Pixel wrote: > raise Foo 1 > raise Foo > > same for this. I understand why it typechecks, but couldn't there be > a special check for this since it can't be useful (or can it??) Interesting, but I don't see how to prevent the type checker to give the type 'a to "raise Foo". Or else, you can add a type constraint, but it is constraining... and it depends on where this "raise" statement takes place. I wonder whether there are situations where it could be a problem? Sometimes, a missing semicolon can introduce typing errors or perhaps work with different semantics (what is very bad). But here, I don't see, since, generally, nobody add another statement after a "raise". Does anybody have an example? -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-27 20:30 ` Daniel de Rauglaudre @ 2001-10-27 23:44 ` Pixel 2001-10-28 19:47 ` Nicolas George 1 sibling, 0 replies; 11+ messages in thread From: Pixel @ 2001-10-27 23:44 UTC (permalink / raw) To: Daniel de Rauglaudre; +Cc: caml-list Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr> writes: > I wonder whether there are situations where it could be a problem? > Sometimes, a missing semicolon can introduce typing errors or perhaps > work with different semantics (what is very bad). But here, I don't > see, since, generally, nobody add another statement after a "raise". > Does anybody have an example? well, mine was not a big deal, twas something like this: failwith "foo %s bar" (foo bar) which of course should have been failwith (sprintf "foo %s bar" (foo bar)) it didn't take me long to understand what the pb was, but at runtime ;p ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-27 20:30 ` Daniel de Rauglaudre 2001-10-27 23:44 ` Pixel @ 2001-10-28 19:47 ` Nicolas George 1 sibling, 0 replies; 11+ messages in thread From: Nicolas George @ 2001-10-28 19:47 UTC (permalink / raw) To: caml-list Le sextidi 6 brumaire, an CCX, Daniel de Rauglaudre a écrit : > I wonder whether there are situations where it could be a problem? > Sometimes, a missing semicolon can introduce typing errors or perhaps > work with different semantics (what is very bad). But here, I don't > see, since, generally, nobody add another statement after a "raise". > Does anybody have an example? It make sense to add statements after a raise if the raise in inside an if...else: if not (is_valid argument) then raise Some_exception; do_something argument ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-27 19:51 [Caml-list] raise extra arg ignored Pixel 2001-10-27 20:30 ` Daniel de Rauglaudre @ 2001-10-29 10:26 ` Xavier Leroy 2001-10-30 21:29 ` Pierre Weis 2001-11-26 15:12 ` Fergus Henderson 1 sibling, 2 replies; 11+ messages in thread From: Xavier Leroy @ 2001-10-29 10:26 UTC (permalink / raw) To: Pixel; +Cc: caml-list > failwith "foo" "bar" > failwith "foo" > > are equivalent. > > exception Foo;; > raise Foo 1 > raise Foo > > same for this. Yes. For additional fun, you could do print_string (raise Foo);; print_int (raise Foo);; raise Foo + 2;; Notice that this also works for certain non-terminating functions: let rec f() = f();; f () "bar";; print_string (f());; print_int (f());; f() + 2;; > I understand why it typechecks, but couldn't there be a special > check for this since it can't be useful (or can it??) Possibly, but that would not be easy to do: we'd have to wait until type inference for the phrase is completed, remember the principal types inferred for each sub-expression, and apply ad-hoc checks such as "warn if an expression of principal type 'a ('a being generalizable in the context) is applied as if it were a function". This really doesn't fit well in the current OCaml type inference technology. - Xavier Leroy ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-29 10:26 ` Xavier Leroy @ 2001-10-30 21:29 ` Pierre Weis 2001-10-30 22:17 ` Dave Mason 2001-11-26 15:12 ` Fergus Henderson 1 sibling, 1 reply; 11+ messages in thread From: Pierre Weis @ 2001-10-30 21:29 UTC (permalink / raw) To: Xavier Leroy; +Cc: pixel, caml-list > > failwith "foo" "bar" > > failwith "foo" > > > > are equivalent. > > > > exception Foo;; > > raise Foo 1 > > raise Foo > > > > same for this. > > Yes. For additional fun, you could do > print_string (raise Foo);; > print_int (raise Foo);; > raise Foo + 2;; > > Notice that this also works for certain non-terminating functions: > let rec f() = f();; > f () "bar";; > print_string (f());; > print_int (f());; > f() + 2;; > > > I understand why it typechecks, but couldn't there be a special > > check for this since it can't be useful (or can it??) > > Possibly, but that would not be easy to do: we'd have to wait until > type inference for the phrase is completed, remember the principal > types inferred for each sub-expression, and apply ad-hoc checks such as > "warn if an expression of principal type 'a ('a being generalizable in > the context) is applied as if it were a function". This really > doesn't fit well in the current OCaml type inference technology. Absolutely. This is particularly difficult if you consider that none of those expressions can be generalized according to the current type discipline (since, being applications, those expressions are ``expansive'' or equivalently they are not ``syntactic values''). So the criterion to emit the warning would be even more complex and unclear ... Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-30 21:29 ` Pierre Weis @ 2001-10-30 22:17 ` Dave Mason 2001-10-31 17:57 ` Daniel de Rauglaudre 0 siblings, 1 reply; 11+ messages in thread From: Dave Mason @ 2001-10-30 22:17 UTC (permalink / raw) To: caml-list The `obvious' solution is to make raise be a statement rather than a function. That has the added benefit of making raise a little clearer, to wit, instead of: ; ocaml Objective Caml version 3.02 # exception Foo of int;; exception Foo of int # raise Foo 42;; Characters 6-9: The constructor Foo expects 1 argument(s), but is here applied to 0 argument(s) # raise Foo 42 could be interpreted properly (i.e. as raise (Foo 42) This is one of the few ways that I prefer Java syntax over ocaml syntax. ../Dave ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-30 22:17 ` Dave Mason @ 2001-10-31 17:57 ` Daniel de Rauglaudre 2001-10-31 19:09 ` Remi VANICAT 0 siblings, 1 reply; 11+ messages in thread From: Daniel de Rauglaudre @ 2001-10-31 17:57 UTC (permalink / raw) To: caml-list On Tue, Oct 30, 2001 at 05:17:37PM -0500, Dave Mason wrote: > The `obvious' solution is to make raise be a statement rather than a > function. That has the added benefit of making raise a little > clearer, to wit, instead of: I thought of it, but it would not work. If "raise something" is an expression, as there is a rule "expr expr", then you can syntactically write: exception Foo;; raise Foo 33 "bar" true;; No solution. -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-31 17:57 ` Daniel de Rauglaudre @ 2001-10-31 19:09 ` Remi VANICAT 2001-11-01 10:01 ` Daniel de Rauglaudre 0 siblings, 1 reply; 11+ messages in thread From: Remi VANICAT @ 2001-10-31 19:09 UTC (permalink / raw) To: caml-list Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr> writes: > On Tue, Oct 30, 2001 at 05:17:37PM -0500, Dave Mason wrote: > > > The `obvious' solution is to make raise be a statement rather than a > > function. That has the added benefit of making raise a little > > clearer, to wit, instead of: > > I thought of it, but it would not work. If "raise something" is an > expression, as there is a rule "expr expr", then you can syntactically > write: > > exception Foo;; > raise Foo 33 "bar" true;; > > No solution. Even if we change the priority of the application of raise ? -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-31 19:09 ` Remi VANICAT @ 2001-11-01 10:01 ` Daniel de Rauglaudre 0 siblings, 0 replies; 11+ messages in thread From: Daniel de Rauglaudre @ 2001-11-01 10:01 UTC (permalink / raw) To: caml-list Hi, On Wed, Oct 31, 2001 at 08:09:37PM +0100, Remi VANICAT wrote: > Even if we change the priority of the application of raise ? It works indeed. I was sure that it would not but I tested and there is indeed a syntax error at "raise Foo 3". It works, not because of priorities, but because the application is defined as a list of simple expressions. If the construction "raise" is defined as expression (not "simple"), it cannot be used in an application. --- I am a little bit surprised, because yacc sometimes bypass priorities to avoid syntax errors: for example "comma" as more priority than "as": x, y as z means (x, y) as z but: function x, y as z, t -> x is however accepted, althought it should be a syntax error at the comma after "z". This makes me wonder about camlp4, because to resolve this problem of "comma" and "as", I added a rule to "try again" the continuation of a grammar entry when a syntax error about priorities happens. And because of that, I cannot prevent "raise Foo 3" to be accepted in camlp4o. -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Caml-list] raise extra arg ignored 2001-10-29 10:26 ` Xavier Leroy 2001-10-30 21:29 ` Pierre Weis @ 2001-11-26 15:12 ` Fergus Henderson 1 sibling, 0 replies; 11+ messages in thread From: Fergus Henderson @ 2001-11-26 15:12 UTC (permalink / raw) To: Xavier Leroy; +Cc: Pixel, caml-list On 29-Oct-2001, Xavier Leroy <xavier.leroy@inria.fr> wrote: > > failwith "foo" "bar" > > failwith "foo" > > > > are equivalent. > > > > exception Foo;; > > raise Foo 1 > > raise Foo > > > > same for this. > > Yes. For additional fun, you could do > print_string (raise Foo);; > print_int (raise Foo);; > raise Foo + 2;; > > Notice that this also works for certain non-terminating functions: [...] > > I understand why it typechecks, but couldn't there be a special > > check for this since it can't be useful (or can it??) > > Possibly, but that would not be easy to do: we'd have to wait until > type inference for the phrase is completed, remember the principal > types inferred for each sub-expression, and apply ad-hoc checks such as > "warn if an expression of principal type 'a ('a being generalizable in > the context) is applied as if it were a function". This really > doesn't fit well in the current OCaml type inference technology. How about ignoring the types, and instead issuing a warning whenever any expression which always raises an exception is used as a function argument, or as the function term in a function application? -- Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2001-11-26 15:13 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-10-27 19:51 [Caml-list] raise extra arg ignored Pixel 2001-10-27 20:30 ` Daniel de Rauglaudre 2001-10-27 23:44 ` Pixel 2001-10-28 19:47 ` Nicolas George 2001-10-29 10:26 ` Xavier Leroy 2001-10-30 21:29 ` Pierre Weis 2001-10-30 22:17 ` Dave Mason 2001-10-31 17:57 ` Daniel de Rauglaudre 2001-10-31 19:09 ` Remi VANICAT 2001-11-01 10:01 ` Daniel de Rauglaudre 2001-11-26 15:12 ` Fergus Henderson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox