| Anonymous | Login | Signup for a new account | 2013-05-25 22:16 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0005362 | OCaml | OCaml general | public | 2011-09-27 11:03 | 2011-10-05 19:07 | ||||||
| Reporter | Dmitry Grebeniuk | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | always | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 3.12.1 | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0005362: "let _ : t = v;;" is not accepted without camlp4o | ||||||||||
| Description | "let _ : t = v" should be accepted just like "let x : t = v" even without camlp4o: $ ocaml Objective Caml version 3.12.1+rc1 # let x : int = 1;; val x : int = 1 # let _ : int = 1;; Error: Syntax error # #use "topfind";; - : unit = () Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads - : unit = () # #camlp4o;; /home/gds/dev/ovm/ocaml/lib/dynlink.cma: loaded /home/gds/dev/ovm/ocaml/lib/camlp4: added to search path /home/gds/dev/ovm/ocaml/lib/camlp4/camlp4o.cma: loaded Camlp4 Parsing version 3.12.1+rc1 # let x : int = 1;; val x : int = 1 # let _ : int = 1;; - : int = 1 # Also it's strange that toplevel output ("- : int = 1") differs from revised syntax: $ ocaml Objective Caml version 3.12.1+rc1 # #use "topfind";;; - : unit = () Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads - : unit = () # #camlp4r;; /home/gds/dev/ovm/ocaml/lib/dynlink.cma: loaded /home/gds/dev/ovm/ocaml/lib/camlp4: added to search path /home/gds/dev/ovm/ocaml/lib/camlp4/camlp4r.cma: loaded Camlp4 Parsing version 3.12.1+rc1 # value _ : int = 1; # (there is no output at all) | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0006132) garrigue (manager) 2011-09-27 12:21 |
We have here a subtle point. In the OCaml grammar, a let definition is either let <pattern> = <expression> or let <ident> <args ...> [: <type>] = <expression> In patterns, a type annotation requires parentheses, so let (_ : <type>) = <expression> is of course ok, but let _ : <type> = <expression> doesn't fit either. The specification of the manual fits this description. |
|
(0006133) Dmitry Grebeniuk (reporter) 2011-09-27 16:15 |
Yes, you are right. So, please treat this issue not as "bug report", but as a "feature wish". It's very convenient to think about "_" pattern as "/dev/null variable", "sink variable", "value that is will be bound to anything you'll bind it to". So, I personally like the #camlp4o and #camlp4r behaviour. However, I'm using revised syntax almost always, so this issue will cause inconvenience/misunderstanding only for "plain toplevel users". |
|
(0006143) Julien Signoles (reporter) 2011-10-04 09:51 |
Usually I use "let __ : type = expr" (double underscore) when I want to use such a pattern. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2011-09-27 11:03 | Dmitry Grebeniuk | New Issue | |
| 2011-09-27 12:21 | garrigue | Note Added: 0006132 | |
| 2011-09-27 16:15 | Dmitry Grebeniuk | Note Added: 0006133 | |
| 2011-10-04 09:51 | Julien Signoles | Note Added: 0006143 | |
| 2011-10-05 19:07 | doligez | Severity | minor => feature |
| 2011-10-05 19:07 | doligez | Status | new => acknowledged |
| Copyright © 2000 - 2011 MantisBT Group |