Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List.unsafe_tl, List.unsafe_hd #2919

Closed
vicuna opened this issue Jul 8, 2004 · 1 comment
Closed

List.unsafe_tl, List.unsafe_hd #2919

vicuna opened this issue Jul 8, 2004 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 8, 2004

Original bug ID: 2919
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Evgeny Chukreev
Version:
OS:
Submission from: host134.t3n.sotline.ru (81.1.200.134)

It will be nice to have these functions in 3.08:
List.unsafe_tl ("%list_unsafe_tl")
List.unsafe_hd ("%list_unsafe_hd")

let unsafe_hd list : ('a list -> 'a) =
Obj.obj (Obj.field (Obj.repr list) 0))
and unsafe_tl list : ('a list -> 'a list) =
Obj.obj (Obj.field (Obj.repr list) 1))

  • works even slowly than List.hd and List.tl.
@vicuna vicuna closed this as completed Jul 8, 2004
@vicuna
Copy link
Author

vicuna commented Jul 8, 2004

Comment author: administrator

From: sjah@land.ru

It will be nice to have these functions in 3.08:
List.unsafe_tl ("%list_unsafe_tl")
List.unsafe_hd ("%list_unsafe_hd")

Please, no!

If you really need it, here it is, with its consequence:

external hd : 'a list -> 'a = "%field0";;
hd [1;2];;
external tl : 'a list -> 'a list = "%field1";;
tl [1;2];;
hd [];;
Segmentation fault

Jacques

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant