-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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.cons function #5960
Comments
Comment author: @gasche The pros of the change are to make life marginally nicer for people using cons in a higher-order context, where they're pained by constructors not being functions already. The downsides are the risk of breaking code among people that do a local open of List in a scope where they have a My gut feeling would be that it is not worth it. |
Comment author: @lpw25
Your probably right. I was surprised that it didn't already exist, but it is hardly a major inconvenience to write (fun hd tl -> hd :: tl). |
Comment author: @gasche The standard library is between two rocks and a hard place these days. Adding stuff to it would be nice, but long-term maintainers frown over the idea of how far they could have to go and, more importantly, how much code they would have to maintain. There is this known (but not yet fully realized, I'm afraid) idea that it could become only the "library of the compiler", with external users using Batteries, Core or something else outside the compiler's scope as a base for development; to support this view we're not supposed to add too much stuff to it. But on the same side, additions to it (even if they're purely meant to help with the internal codebase, not the users) are generally not welcome, because it can introduce the breakages I mentioned and others (for example, the (much welcome) Hashtbl change of 4.00 made life quite hard for Batteries developpers). So you've got the strict conservative policies of an extenral library that users depend on and don't expect to change too much, and at the same time the strict minimalist policies of an internal library that has to be maintained in-house. |
Comment author: @yakobowski Frama-C does not redefine List, thanks for him :-) Real troubles arise when {Set,Map,Hashtbl}.S change, not when something is added at toplevel in a module such as List:
All joking apart, please do not use the potential breakage of packages such as Frama-C as a reason for not improving the standard library. That List.cons is missing is a minor inconvenience, but it remains an inconvenience that should ultimately be addressed. Writing (fun hd tl -> hd :: tl) instead of List.cons results in harder to read code (what is this closure doing? This requires a bit of parsing), and in longer lines. |
Comment author: @protz
Which is an argument for not ever ever modifying the standard library. I don't think we should do that. Just for the record, List.mapi and iteri were added in the 4.00 series, so apparently there's nothing against adding stuff in the List module. And by the way, I just ran in this particular shortcoming a few days ago, so unless someone speaks up, I'll probably commit the suggested change sometime this week. Cheers, jonathan |
Comment author: @gasche A compelling argument. Go ahead! |
Comment author: @lpw25 This issue is marked as "won't fix", but Jonathan said that he would actually "fix" it, although he doesn't seem to have got around to it yet. What should the correct status of this issue be? Is it too late to add the "cons" function for 4.01.0 (it's a feature but a very small one)? |
Comment author: @gasche I don't have much of an opinion, but changed the status so that it doesn't block things (I don't know if anybody cares, but well). |
Comment author: @dbuenzli Today it seems, after all these years, I could no longer handle this. So I made a pull request: A few arguments w.r.t discussion (most of them already made by Boris):
|
Comment author: @zoggy Just an idea: Since we can now associate attributes (like ocaml.deprecated) to values, we could use attributes like ocaml.since and add a command line argument to tell which ocaml "version" of the library should be available. With something like |
Comment author: @alainfrisch
It's ok for attributes to control warnings, optimizations, etc, but it seems a bad idea to have them impact well-typedness. |
Comment author: @lpw25
I agree. However having a |
Comment author: @gasche I just added List.cons to trunk -- it should be included in 4.03. |
Original bug ID: 5960
Reporter: @lpw25
Assigned to: @gasche
Status: resolved (set by @gasche on 2013-03-30T18:21:08Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 4.00.1
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Related to: #6659
Monitored by: @dbuenzli
Bug description
A List.cons function would be mildly useful:
let cons hd tl = hd :: tl
The text was updated successfully, but these errors were encountered: