You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5351 Reporter: gerd Assigned to:@lefessan Status: closed (set by @xavierleroy on 2013-08-31T10:44:24Z) Resolution: suspended Priority: normal Severity: minor Version: 3.12.1 Category: ~DO NOT USE (was: OCaml general) Monitored by: abdallah @protz@lefessan@ygrek@hcarty@Chris00
Bug description
I think this function definition is reasonable, but the compiler rejects it with syntax error:
let _ (x : some_object_type) =
(x :> some_super_object_type)
This is useful as a compile-time assertion that some_object_type is a subtype of some_super_object_type. The compiler accepts this if I change the function name to _f. However, I'm not interested in this function as such, but only in the effect of the definition on type checking.
Additional information
Ideally, a function with name _ would not generate code at all.
Btw, let _ = fun x -> x is accepted.
The text was updated successfully, but these errors were encountered:
I personally would use it to disable some part of the code — say some tests during development that I would like to keep for reference (this is in research code, not production one). It is easy to switch from “let () =” to “let _ () =”.
"_" is a pattern, not an identifier, so
let _ = ...
is accepted just like
let (x,y,z) = ...
is accepted. However, it wouldn't make sense to accept
let (x,y,z) arg = ...
as some kind of function definition... So, for this reason, I'm uncomfortable with
let _ arg = ...
In your particular example, what about writing the below?
let _ = fun (x : some_object_type) -> (x :> some_super_object_type)
Original bug ID: 5351
Reporter: gerd
Assigned to: @lefessan
Status: closed (set by @xavierleroy on 2013-08-31T10:44:24Z)
Resolution: suspended
Priority: normal
Severity: minor
Version: 3.12.1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: abdallah @protz @lefessan @ygrek @hcarty @Chris00
Bug description
I think this function definition is reasonable, but the compiler rejects it with syntax error:
let _ (x : some_object_type) =
(x :> some_super_object_type)
This is useful as a compile-time assertion that some_object_type is a subtype of some_super_object_type. The compiler accepts this if I change the function name to _f. However, I'm not interested in this function as such, but only in the effect of the definition on type checking.
Additional information
Ideally, a function with name _ would not generate code at all.
Btw, let _ = fun x -> x is accepted.
The text was updated successfully, but these errors were encountered: