Naming conventions discussion #1251
Replies: 5 comments 22 replies
-
Initial FeelingsWhile this may be biased and likely won't make it in, for the purposes of discussion, I'll write down my thoughts. The locality is roughly perfect, consider the following example: (sorted ["sort" "sort-by" "sort-by!" "sort!"])
# => @["sort" "sort!" "sort-by" "sort-by!"]
(sorted ["sorted" "sorted-by" "sort-by" "sort"])
# => @["sort" "sort-by" "sorted" "sorted-by"] With Furthermore, typically, "variants" will have a Initial ProposalFor the entirety of this, when you see "function", this typically includes "macro", unless those are explicitly mentioned.
These additional ideas I have in the back of my mind, and should not be considered part of the concrete proposal, but discussion items:
Additional ContextBased on the prior art, it definitely seems like Janet has a bit of an identity question. You cannot I've previously tried to remedy this at least in the C API by making utilities that let you have a c-string out of both buffers and strings, but since buffers aren't guaranteed to be zero-terminated, that was suboptimal. One advantage of enforcing the above is to make it more of an equal playing-ground. Interesting Side-EffectsSince functions definitionally return their original type, immutable functions like (def a @{:a :b})
(def b (put a :a :c))
# a is @{:a :b}, b is @{:a :c}: still mutable It also means that mutable functions don't need to worry about many things, since they definitionally only accept mutable inputs, and therefore can never dynamic-dispatch to an immutable function type, and thus will never receive back an immutable type. |
Beta Was this translation helpful? Give feedback.
-
Just throwing my 2-cents in, but I very much like how Julia adds |
Beta Was this translation helpful? Give feedback.
-
Common functions with uncommon namesThe primary example for this is > (unfold |(< $ 100) + 0 1)
@[0 1 1 2 3 5 8 13 21 34 55 89] Super useful, a shame it's not there. Uncommon functions with common namesThe primary example for this is > (chr 65)
"A" In a variadic form, (buffer/push @"" ;(range 65 91))
# vs.
(chr ;(range 65 91)) |
Beta Was this translation helpful? Give feedback.
-
The Janet name for function that I would expect to be called In OCaml's There's a recent naming choice in the current stdlib that is inconsistent: |
Beta Was this translation helpful? Give feedback.
-
Sorry to spoil the bike-shedding fun, but we are absolutely not renaming Also yes, I still don't want As far as strict rules as have been proposed here, they will not be maintained over time unless they can be mechanically enforced (or are trivial to enforce). Even in the Clojure/Lisp world, I have seen debate on whether or not a
Yup. I don't plan on adding I do think the standard library could be improved, but it would be more related to things like redoing the module system to be simpler, removing functionality like |
Beta Was this translation helpful? Give feedback.
-
There's general interest in improving the naming conventions and the consistency across the stdlib.
Let's discuss what they should be.
Factors to consider:
sort
(new copy) andsort!
(in-place). They will be next to each other when sorted.We should cover at least:
Of additional note: in 2021 bakpakin explicitly said he doesn't want too many
!
s in the stdlib.Whether this is still the case is up to him.
Most
!
-type functions can be converted into immutables fairly easily, however:!
function.Prior art: #626 #1248
Will edit any of the above if something new is brought to my attention.
Beta Was this translation helpful? Give feedback.
All reactions