Re: Why does the `def-` not exist?
That's what I do ! However I have the gut feeling that the :private metadata was designed for exactly this purpose, and many people (including me) don't use it because they don't want to rely on dirty hacks to access implementation from the outside. That's why I half-jokingly suggested the compiler could just ignore it. This would foster its use so we could fully leverage tools designed for it such as those Alex cited. We could still rely on linters to make sure we don't accidentally call implementation directly in production code. Or maybe a compiler warning is a good compromise. Of course this is just random thoughts, I started learning clojure around 1.6 and I may be missing something obvious, so please correct me if this has already been discussed before. On Monday, March 5, 2018 at 9:26:09 AM UTC+1, Chris Ford wrote: > > This isn't foolproof Léo, but sometimes folks use docstrings to make that > distinction i.e. if it's got a docstring it's part of the public API. > Codox, for example, takes this approach when deciding what to include in > generated API documentation. > > On 4 March 2018 at 12:50, Léo Noel > > wrote: > >> Or maybe people are confused because the :private metadata *complects* >> two separate concerns : *API commitment* and *visibility*. >> If there was a way to programmatically make the distinction between >> implementation and API without impacting visibility, it would be >> tremendously valuable for tooling and I would definitely use it. >> >> >> On Saturday, March 3, 2018 at 6:02:00 PM UTC+1, Alex Miller wrote: >>> >>> > ^:private is the stale and sleazy co-conspirator of another blunt >>> instrument, the whole-ns :use. >>> >>> It’s also useful for anything that uses the var meta to show you only >>> public vars in an ns, such as dir, ns-publics, etc. those are all useful >>> and would affect your repl experience even if you never :use or :refer >>> :all. >>> >>> I find people have different relationships with :private depending on >>> what kind of work they do. It’s very useful in in libs for delineating >>> public apis, much less important in an app context. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
This isn't foolproof Léo, but sometimes folks use docstrings to make that distinction i.e. if it's got a docstring it's part of the public API. Codox, for example, takes this approach when deciding what to include in generated API documentation. On 4 March 2018 at 12:50, Léo Noel wrote: > Or maybe people are confused because the :private metadata *complects* > two separate concerns : *API commitment* and *visibility*. > If there was a way to programmatically make the distinction between > implementation and API without impacting visibility, it would be > tremendously valuable for tooling and I would definitely use it. > > > On Saturday, March 3, 2018 at 6:02:00 PM UTC+1, Alex Miller wrote: >> >> > ^:private is the stale and sleazy co-conspirator of another blunt >> instrument, the whole-ns :use. >> >> It’s also useful for anything that uses the var meta to show you only >> public vars in an ns, such as dir, ns-publics, etc. those are all useful >> and would affect your repl experience even if you never :use or :refer >> :all. >> >> I find people have different relationships with :private depending on >> what kind of work they do. It’s very useful in in libs for delineating >> public apis, much less important in an app context. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
Or maybe people are confused because the :private metadata *complects* two separate concerns : *API commitment* and *visibility*. If there was a way to programmatically make the distinction between implementation and API without impacting visibility, it would be tremendously valuable for tooling and I would definitely use it. On Saturday, March 3, 2018 at 6:02:00 PM UTC+1, Alex Miller wrote: > > > ^:private is the stale and sleazy co-conspirator of another blunt > instrument, the whole-ns :use. > > It’s also useful for anything that uses the var meta to show you only > public vars in an ns, such as dir, ns-publics, etc. those are all useful > and would affect your repl experience even if you never :use or :refer > :all. > > I find people have different relationships with :private depending on what > kind of work they do. It’s very useful in in libs for delineating public > apis, much less important in an app context. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
> ^:private is the stale and sleazy co-conspirator of another blunt instrument, > the whole-ns :use. It’s also useful for anything that uses the var meta to show you only public vars in an ns, such as dir, ns-publics, etc. those are all useful and would affect your repl experience even if you never :use or :refer :all. I find people have different relationships with :private depending on what kind of work they do. It’s very useful in in libs for delineating public apis, much less important in an app context. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
^:private is the stale and sleazy co-conspirator of another blunt instrument, the whole-ns :use. Besides relegating inner-workings to a separate ns: You can gracefully omit a function from auto-generated docs by putting its description in a comment instead of a docstring. It would, likewise, be within the powers of auto-completing editors to disfavor undocumented symbols in other ns. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
I'm not advocating for it's removal though. That would be silly. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
"University me" is yelling incredulously in my ear for saying this, but ... I have no use for private vars and private functions anymore. When that voice persuades me to evaluate a namespace for visibility I always feel like I'm over-engineering. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
My opinionated 2 cents : I think the whole visibility feature was a mistake, it doesn't provide any value and it should be taken away from the compiler (I guess it would not break anything to ignore :private metadata and make every var public). Every single time I asked myself whether I needed a var to be private, I ended up to the conclusion that I did not need this feature. The most common scenario is when the value is an implementation detail. In this case there's generally good reasons to allow other namespaces to use it : you may want to test it in isolation, you may want to tinker with the implementation from another place. Your requirement is purely social, what you actually need is a way to tell your users "use this at your own risk, it expects sanitized input, it can break in future versions" and there's a bunch of ways to do it, as many already said : move it in a separate namespace, do not document it, use a naming convention (a prefix "-" or a suffix "*" are pretty common). Your users are not children : inform, don't forbid. If you ignore warnings, you deserve production bugs. Now for the very exceptional case where you're positively sure a value won't make any sense outside of a restricted scope, clojure has this useful feature called lexical scoping : (ns my.public.api) (let [private (here be dragons)] (defn do-stuff [args] (stuff private args)) (defn do-things [args] (things private args))) Visibility enforced by the compiler. Guaranteed. Your IDE won't even suggest it. On Thursday, March 1, 2018 at 12:35:27 PM UTC+1, Leon Grapenthin wrote: > > I guess unqualified meta keywords are reserved for the compiler anyway so > it could just warn if it doesn't know a unqualified kw. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
I guess unqualified meta keywords are reserved for the compiler anyway so it could just warn if it doesn't know a unqualified kw. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
> > I don't see how you could accidentally mistype it (never happened IME) or > the need for compiler aid You wouldn't even know though: (ns ns1) (def ^:pribate typo "typo") (def ^:private correct "correct") ^:private (def misplaced1 "misplaced1") (^:private def misplaced2 "misplaced2") (ns ns2 (:require [ns1 :as ns1])) ns1/typo ;ns1/correct ; Throws proper not public compiler error ns1/misplaced1 ns1/misplaced2 ns1/misplaced2 Because all wrong declarations of private are valid to the compiler. Compiler auto injection on postfix magic I'm strongly opposed to Me two, I'm more behind having a dedicated construct reserved for compiler directives which is not abusing the metadata feature, and thus could also be checked for valid syntax at compile time. Something that could be used for type hints, private, dynamic, etc. instead of meta. (def +private +dynamic wtv "some thing") ; compiles fine (def +pribate wtv "some thing") ; Compile error, +pribate is not a valid compiler hint, did you mean +private? (defn +private +dynamic wtvfn [] "some wtv thing returned") ; Compile error, fn can not be made dynamic. Then annotations could be a user land feature, not something that is also used to give the compiler compile hints and configurations. Well, it would also be that for backwards compatibility, but alas. Anyways, probably better things to do then implement such a feature, also maybe its a bad idea too. On Wednesday, 28 February 2018 11:58:05 UTC-8, Leon Grapenthin wrote: > > The one issue with the lack of def- is the existence of defn-. If defn- > didn't exist, no one would ask for def-. I believe this is where the > "regret" comes from. > The other issue with the lack of def- is that its annoying to type > ^:prviate. I don't see how you could accidentally mistype it (never > happened IME) or the need for compiler aid. > If beginners think that there is a magic postfix syntax, I don't see how > this is a problem. They are beginners and naturally there will be many > things that fail their intuition. > Compiler auto injection on postfix magic I'm strongly opposed to. > > @Alex thanks for your long reply yesterday and the statistics! I'll get > back to that. > > > On Wednesday, February 28, 2018 at 8:06:51 PM UTC+1, Didier wrote: >> >> I think the issue is not with the lack of def-, but with the use of >> metadata for private, as well as the presence of defn-. >> >> Becauae defn- exists, most newcomers think that postfix - on var defining >> special forms, macros and fns is how you mark things as private. >> >> But its not, defn- is a syntactic hack. >> >> The compiler and runtime looks for the private metadata on the Var for >> that. But metadata is easy to typo and always confusing as to where it >> needs to be inserted. >> >> Not sure there's a solution. Maybe reserved meta could be turned into a >> different syntax of reserved keywords which the compiler could validate if >> its misplaced or mistyped? Or postfix - on any first symbol in a form could >> be special syntax where the compiler auto-injects the private meta on the >> returned Var. >> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
Hi Leon, as Alex said above, if you really need something I would recommend adding it in a library. I'm sure you will encounter more scenarios in the future where you need things that are not in the core language. You can put them in the same library. I don't think anyone will (or should) blame you for doing this. As for beginners encountering this def- issue, maybe it is a good opportunity to talk to them about Lisp being a programmable programming language. That's one of the big advantages of Lisp. It would be unfortunate to restrict ourselves to a way of thinking inherited from inferior languages. It shouldn't be a lot of work. A quick copy-and-paste from `defn-` gave me this: (defmacro def- "same as def, yielding non-public def" [name & decls] (list* `def (with-meta name (assoc (meta name) :private true)) decls)) On Wed, Feb 28, 2018 at 1:58 PM, Leon Grapenthin wrote: > The one issue with the lack of def- is the existence of defn-. If defn- > didn't exist, no one would ask for def-. I believe this is where the > "regret" comes from. > The other issue with the lack of def- is that its annoying to type > ^:prviate. I don't see how you could accidentally mistype it (never > happened IME) or the need for compiler aid. > If beginners think that there is a magic postfix syntax, I don't see how > this is a problem. They are beginners and naturally there will be many > things that fail their intuition. > Compiler auto injection on postfix magic I'm strongly opposed to. > > @Alex thanks for your long reply yesterday and the statistics! I'll get > back to that. > > > On Wednesday, February 28, 2018 at 8:06:51 PM UTC+1, Didier wrote: >> >> I think the issue is not with the lack of def-, but with the use of >> metadata for private, as well as the presence of defn-. >> >> Becauae defn- exists, most newcomers think that postfix - on var defining >> special forms, macros and fns is how you mark things as private. >> >> But its not, defn- is a syntactic hack. >> >> The compiler and runtime looks for the private metadata on the Var for >> that. But metadata is easy to typo and always confusing as to where it >> needs to be inserted. >> >> Not sure there's a solution. Maybe reserved meta could be turned into a >> different syntax of reserved keywords which the compiler could validate if >> its misplaced or mistyped? Or postfix - on any first symbol in a form could >> be special syntax where the compiler auto-injects the private meta on the >> returned Var. >> >> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
The one issue with the lack of def- is the existence of defn-. If defn- didn't exist, no one would ask for def-. I believe this is where the "regret" comes from. The other issue with the lack of def- is that its annoying to type ^:prviate. I don't see how you could accidentally mistype it (never happened IME) or the need for compiler aid. If beginners think that there is a magic postfix syntax, I don't see how this is a problem. They are beginners and naturally there will be many things that fail their intuition. Compiler auto injection on postfix magic I'm strongly opposed to. @Alex thanks for your long reply yesterday and the statistics! I'll get back to that. On Wednesday, February 28, 2018 at 8:06:51 PM UTC+1, Didier wrote: > > I think the issue is not with the lack of def-, but with the use of > metadata for private, as well as the presence of defn-. > > Becauae defn- exists, most newcomers think that postfix - on var defining > special forms, macros and fns is how you mark things as private. > > But its not, defn- is a syntactic hack. > > The compiler and runtime looks for the private metadata on the Var for > that. But metadata is easy to typo and always confusing as to where it > needs to be inserted. > > Not sure there's a solution. Maybe reserved meta could be turned into a > different syntax of reserved keywords which the compiler could validate if > its misplaced or mistyped? Or postfix - on any first symbol in a form could > be special syntax where the compiler auto-injects the private meta on the > returned Var. > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
I think the issue is not with the lack of def-, but with the use of metadata for private, as well as the presence of defn-. Becauae defn- exists, most newcomers think that postfix - on var defining special forms, macros and fns is how you mark things as private. But its not, defn- is a syntactic hack. The compiler and runtime looks for the private metadata on the Var for that. But metadata is easy to typo and always confusing as to where it needs to be inserted. Not sure there's a solution. Maybe reserved meta could be turned into a different syntax of reserved keywords which the compiler could validate if its misplaced or mistyped? Or postfix - on any first symbol in a form could be special syntax where the compiler auto-injects the private meta on the returned Var. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
> That' because you don't know the zen of Clojure core team? the zen it > would be more convenient if has 'foo' function in core lib, ok, let's add it. > If you and I (not the member of core team) want to give some advice, we will > be ignored. I’m sure it’s convenient to believe this but even a cursory glance at the change log shows that we incorporate many enhancements and improvements from the community. Between using a language that says yes to every idea vs one that tries to weigh the tradeoffs and makes choices consistent with a vision, I know I’d rather use the latter every time. Brian Goetz’s talk about the stewardship of Java is a pretty good resource on this I think. https://youtube.com/watch?v=2y5Pv4yN0b0 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
That' because you don't know the zen of Clojure core team? the zen it would be more convenient if has 'foo' function in core lib, ok, let's add it. If you and I (not the member of core team) want to give some advice, we will be ignored. On Monday, February 26, 2018 at 4:58:43 PM UTC+8, Promise. wrote: > > `defn-` => `defn` > 'def-` => `def` > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
I've never used defn-, ^:private, etc. But I rigorously prepend a prefix to mark private things, e.g. `-this-is-private-and-can-only-be-used-in-current-file`. From my experience, it makes reading/maintaining code much easier, in any programming language. I think I borrowed this convention from Python where _ is used to mark private things. This rule can also be applied in data structures: {:public-api-data ... :-something-users-shouldnt-write-or-read ...}. This happens frequently when writing controlled inputs in React where user is responsible for storing the whole state of the UI control but at the same time it should be prohibited to modify or depend on some "internal" state parts, e.g. {:text "..." :-cursor-position {:x 123 :y 45}}. In rare cases I also extract *.impl.* namespaces, in such case prefixing is not needed but there are more folders, files and jumps between editor tabs. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
> Why not just mark it deprecated and keep it around forever. It’s not deprecated. It’s there, feel free to use it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
> We're not going to add def-. There is regret over even adding defn-, but we don't take things away... Well, that's not really necessary. Why not just mark it deprecated and keep it around forever. That's the Java approach and I think it's pretty reasonable and close to what you aim for. Nothing really gets broken, but you get to nudge people away from using certain problematic APIs. That would also wrap once and for all recurring discussions like this one. I think Clojure's principle of ensuring backwards compatibility is awesome, but I also think there's little harm in deprecating things from time to time. This sends a very strong message to users about the preferred ways of writing in Clojure. On 28 February 2018 at 05:33, Alex Miller wrote: > > On Tuesday, February 27, 2018 at 1:13:52 PM UTC-6, Leon Grapenthin wrote: >> >> I'm sure you'd all use def- if it existed. Even if you could just type >> the much simplified ^:private, use an editor snippet, refer your own macro, >> or create a whole new namespace for it. You'd do none of that. You'd >> totally fall for the trap and type def-, the syntactic aid that should not >> be there. >> > > I'm sure I would. But I don't need it. If it was there, we'd be having the > same discussion about defmacro- or defmulti- or whatever. There has to be a > line somewhere, we drew before def-. > > >> There is "regret over even adding defn-"? You used defn- just recently in >> the tools.deps.alpha core namespace 9 times. Rich used it in clojure.spec >> core namespace 46 times. :))) >> > > Sure, it's there. But if it wasn't, I'd use ^:private and never worry > about it. > > >> Jokes aside, if Rich simply doesn't want it that's fine of course - it's >> his language. However if people ask me again I will just say that instead. >> Believe it or not, I got this question three times last year and the "copy >> N things" argument failed 3/3. >> > > Why even make the argument? If you want def- in your code, then add it. > It's a Lisp - we can all have the language we want. > > The impl ns pattern recommended by Timothy is truly a very good one that I >> apply a lot myself, especially in larger projects and when "private" macro >> helpers are involved (and probably the only solid workaround recommended >> here because it has value in itself). >> > > I use this one as well (I haven't doc'ed it all yet because I'm still > fighting with autodoc) but I consider parts of tools.deps.alpha public and > parts to be "impl". > > >> How much do I def things? - I haven't done the computation but I'm pretty >> sure that I def more things ^:private than I def things public. Little >> lookup tables etc.. Also I'd argue that def is the second most used top >> level form after defn. If not, the ones that come before don't have >> ^:private semantics. Well, if there was any chance for def- left I'd do a >> statistic over available codebases - let me know. >> > > Here's a quick and dirty stat based on the set of ~375 projects I have at > hand: > > [~/code]$ ack -c -h --clojure "\(defn- " */src > 5106 > [~/code]$ ack -c -h --clojure "\(defn " */src > 14344 > [~/code]$ ack -c -h --clojure "\(def " */src > 3924 > [~/code]$ ack -c -h --clojure "\(def \^:private" */src > 559 # note this is a subset of prior, first pair are > disjoint > > defn is 5x more common than def. About 14% of def's are private and 26% of > defns are private. On average I have <2 private defs per project. That > doesn't do much to convince me it's a priority. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
On Tuesday, February 27, 2018 at 1:13:52 PM UTC-6, Leon Grapenthin wrote: > > I'm sure you'd all use def- if it existed. Even if you could just type the > much simplified ^:private, use an editor snippet, refer your own macro, or > create a whole new namespace for it. You'd do none of that. You'd totally > fall for the trap and type def-, the syntactic aid that should not be there. > I'm sure I would. But I don't need it. If it was there, we'd be having the same discussion about defmacro- or defmulti- or whatever. There has to be a line somewhere, we drew before def-. > There is "regret over even adding defn-"? You used defn- just recently in > the tools.deps.alpha core namespace 9 times. Rich used it in clojure.spec > core namespace 46 times. :))) > Sure, it's there. But if it wasn't, I'd use ^:private and never worry about it. > Jokes aside, if Rich simply doesn't want it that's fine of course - it's > his language. However if people ask me again I will just say that instead. > Believe it or not, I got this question three times last year and the "copy > N things" argument failed 3/3. > Why even make the argument? If you want def- in your code, then add it. It's a Lisp - we can all have the language we want. The impl ns pattern recommended by Timothy is truly a very good one that I > apply a lot myself, especially in larger projects and when "private" macro > helpers are involved (and probably the only solid workaround recommended > here because it has value in itself). > I use this one as well (I haven't doc'ed it all yet because I'm still fighting with autodoc) but I consider parts of tools.deps.alpha public and parts to be "impl". > How much do I def things? - I haven't done the computation but I'm pretty > sure that I def more things ^:private than I def things public. Little > lookup tables etc.. Also I'd argue that def is the second most used top > level form after defn. If not, the ones that come before don't have > ^:private semantics. Well, if there was any chance for def- left I'd do a > statistic over available codebases - let me know. > Here's a quick and dirty stat based on the set of ~375 projects I have at hand: [~/code]$ ack -c -h --clojure "\(defn- " */src 5106 [~/code]$ ack -c -h --clojure "\(defn " */src 14344 [~/code]$ ack -c -h --clojure "\(def " */src 3924 [~/code]$ ack -c -h --clojure "\(def \^:private" */src 559 # note this is a subset of prior, first pair are disjoint defn is 5x more common than def. About 14% of def's are private and 26% of defns are private. On average I have <2 private defs per project. That doesn't do much to convince me it's a priority. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
I'm sure you'd all use def- if it existed. Even if you could just type the much simplified ^:private, use an editor snippet, refer your own macro, or create a whole new namespace for it. You'd do none of that. You'd totally fall for the trap and type def-, the syntactic aid that should not be there. There is "regret over even adding defn-"? You used defn- just recently in the tools.deps.alpha core namespace 9 times. Rich used it in clojure.spec core namespace 46 times. :))) Jokes aside, if Rich simply doesn't want it that's fine of course - it's his language. However if people ask me again I will just say that instead. Believe it or not, I got this question three times last year and the "copy N things" argument failed 3/3. The impl ns pattern recommended by Timothy is truly a very good one that I apply a lot myself, especially in larger projects and when "private" macro helpers are involved (and probably the only solid workaround recommended here because it has value in itself). How much do I def things? - I haven't done the computation but I'm pretty sure that I def more things ^:private than I def things public. Little lookup tables etc.. Also I'd argue that def is the second most used top level form after defn. If not, the ones that come before don't have ^:private semantics. Well, if there was any chance for def- left I'd do a statistic over available codebases - let me know. On Tuesday, February 27, 2018 at 2:41:15 AM UTC+1, Alex Miller wrote: > > We're not going to add def-. There is regret over even adding defn-, but > we don't take things away... > > At one point all of the current metadata niceties didn't exist (used to be > #^{:private true} some may recall) and defn- seemed worth doing I presume > (pre-dates my involvementT). But then that was all simplified down to just > ^:private and it's preferred to compose the pieces rather than copy N > things. > > There used to be a slew of these in the old clojure-contrib ( > https://github.com/clojure/clojure-contrib/blob/master/modules/def/src/main/clojure/clojure/contrib/def.clj > > - but no def- !). > > How often do you def things anyway (much less private things)? > > On Monday, February 26, 2018 at 1:50:40 PM UTC-6, Leon Grapenthin wrote: >> >> I have written enough Clojure so that I can assure you that every few >> days when I type ^:private again I am still annoyed by it. Not every time, >> but probably every second or third time. >> >> Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you >> don't hit so often so you have to hit it right. On german keyboards, by the >> way, ^ is a much more annoying character to type. Then a colon, did I miss >> the colon? What did I want to do again? >> >> When prototyping an API ns its important to distinguish what is private >> and what isn't. If only I could just write def- without any overhead. >> >> First world aka best language problems, I know... >> >> But whats left for an enthusiast except bikeshedding? We both know that a >> JIRA discussion on this will not happen due to a lack of importance. And >> unless somebody manages to convince Rich, this feature won't happen. >> >> Fair enough. I'd consider myself a power user since 1.5.1 and value its >> conservative governance above every other kind. >> The "lets not start postfixing lots of macros with -" argument a good one >> in general and probably was a good one at the time. But not in this case >> because defn and def are the two most used and most elementary top level >> forms. >> >> This argument didn't convince anyone who has asked me about this. The >> counter argument goes "I don't want the - postfix for anything else, just >> for def because I use it a lot" -rightfully so. >> >> The lack of def- is just unnecessary typing overhead in lots of cases. It >> could be removed at the cost 5m on a beautiful day. I'd appreciate it :) >> >> On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev >> wrote: >>> >>> - Not that often. When I know for certain, I add ^:private. Not like >>> it's much more work. If I didn't know ahead of time, I would forget to add >>> the private flag in either case. >>> - Never. >>> - Can't recollect such an event. >>> - A few times. As far as I can tell, people appreciate the metadata >>> approach since it is unique and powerful. The lack of one particular >>> non-critical syntactic sugar is never an issue. >>> >>> I won't mind having def- as much as I don't mind not having it. Pretty >>> much the same as for defn- – Earth wouldn't stop turning if you had to type >>> defn ^:private once in a while. >>> >>> And while I agree with you that it would be somewhat useful, >>> bikeshedding only gets you so far. >>> >>> On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: - How many times do you just write (def ...) instead of (def ^:private ...) because you are not sure whether you need the definition yet, wa
Re: Why does the `def-` not exist?
I much more prefer putting implementation details into separate namespaces. >From there it's simple to mark them as :no-doc in some documentation tools so that the vars don't get published. That way I can still test all my code, and yet I can commit to only those namespaces that have published APIs. Or even just putting implementation details behind foo.bar.impl.* So that it's clear that the contents of these namespaces should not be relied on. This is what core.async does, and what a lot of my personal projects do. Timothy On Mon, Feb 26, 2018 at 8:47 PM, Didier wrote: > I’d even be happy if the default was private for def >> > > I actually prefer private everything by default. Its the public things you > want to be reminded to think through carefully. And Var access is pretty > straightforward, in case your using a lib and they forgot to make something > public you really need, but its way too late to change a default like that. > > I think we have to ask ourselves what's the use cases where we use private > on a Var? > > I can think of: > >- When on a function - Implementation details, don't depend on it, it >could change at any time in breaking ways, ie, use at your own risk. >- When on state - You should not read this data directly, its >representation is possibly not easy to consume (another public facing >mechanism exist to get a better representation of it), or you can't depend >on the shape of this data not to change or this data even existing long >term. Thus again, its implementation details. >- When on state - You should not write to this data directly, it has >strict invariants, and so if you do decide to write to it, be careful you >understand and maintain them. > > Can anyone think of more use cases? > > I'm not even sure the concept of private and public make sense. Could > there be a better construct to solve these use cases? > > I feel private would make sense in a security perspective, if there was no > way to bypass it, for say running untrusted code within your code, but > that's not what private does in any way. > > On Monday, 26 February 2018 17:41:15 UTC-8, Alex Miller wrote: >> >> We're not going to add def-. There is regret over even adding defn-, but >> we don't take things away... >> >> At one point all of the current metadata niceties didn't exist (used to >> be #^{:private true} some may recall) and defn- seemed worth doing I >> presume (pre-dates my involvementT). But then that was all simplified down >> to just ^:private and it's preferred to compose the pieces rather than copy >> N things. >> >> There used to be a slew of these in the old clojure-contrib ( >> https://github.com/clojure/clojure-contrib/blob/master/modu >> les/def/src/main/clojure/clojure/contrib/def.clj - but no def- !). >> >> How often do you def things anyway (much less private things)? >> >> On Monday, February 26, 2018 at 1:50:40 PM UTC-6, Leon Grapenthin wrote: >>> >>> I have written enough Clojure so that I can assure you that every few >>> days when I type ^:private again I am still annoyed by it. Not every time, >>> but probably every second or third time. >>> >>> Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you >>> don't hit so often so you have to hit it right. On german keyboards, by the >>> way, ^ is a much more annoying character to type. Then a colon, did I miss >>> the colon? What did I want to do again? >>> >>> When prototyping an API ns its important to distinguish what is private >>> and what isn't. If only I could just write def- without any overhead. >>> >>> First world aka best language problems, I know... >>> >>> But whats left for an enthusiast except bikeshedding? We both know that >>> a JIRA discussion on this will not happen due to a lack of importance. And >>> unless somebody manages to convince Rich, this feature won't happen. >>> >>> Fair enough. I'd consider myself a power user since 1.5.1 and value its >>> conservative governance above every other kind. >>> The "lets not start postfixing lots of macros with -" argument a good >>> one in general and probably was a good one at the time. But not in this >>> case because defn and def are the two most used and most elementary top >>> level forms. >>> >>> This argument didn't convince anyone who has asked me about this. The >>> counter argument goes "I don't want the - postfix for anything else, just >>> for def because I use it a lot" -rightfully so. >>> >>> The lack of def- is just unnecessary typing overhead in lots of cases. >>> It could be removed at the cost 5m on a beautiful day. I'd appreciate it :) >>> >>> On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev >>> wrote: - Not that often. When I know for certain, I add ^:private. Not like it's much more work. If I didn't know ahead of time, I would forget to add the private flag in either case. - Never. - Can't recollect such an event. - A few times. As far as
Re: Why does the `def-` not exist?
> > I’d even be happy if the default was private for def > I actually prefer private everything by default. Its the public things you want to be reminded to think through carefully. And Var access is pretty straightforward, in case your using a lib and they forgot to make something public you really need, but its way too late to change a default like that. I think we have to ask ourselves what's the use cases where we use private on a Var? I can think of: - When on a function - Implementation details, don't depend on it, it could change at any time in breaking ways, ie, use at your own risk. - When on state - You should not read this data directly, its representation is possibly not easy to consume (another public facing mechanism exist to get a better representation of it), or you can't depend on the shape of this data not to change or this data even existing long term. Thus again, its implementation details. - When on state - You should not write to this data directly, it has strict invariants, and so if you do decide to write to it, be careful you understand and maintain them. Can anyone think of more use cases? I'm not even sure the concept of private and public make sense. Could there be a better construct to solve these use cases? I feel private would make sense in a security perspective, if there was no way to bypass it, for say running untrusted code within your code, but that's not what private does in any way. On Monday, 26 February 2018 17:41:15 UTC-8, Alex Miller wrote: > > We're not going to add def-. There is regret over even adding defn-, but > we don't take things away... > > At one point all of the current metadata niceties didn't exist (used to be > #^{:private true} some may recall) and defn- seemed worth doing I presume > (pre-dates my involvementT). But then that was all simplified down to just > ^:private and it's preferred to compose the pieces rather than copy N > things. > > There used to be a slew of these in the old clojure-contrib ( > https://github.com/clojure/clojure-contrib/blob/master/modules/def/src/main/clojure/clojure/contrib/def.clj > > - but no def- !). > > How often do you def things anyway (much less private things)? > > On Monday, February 26, 2018 at 1:50:40 PM UTC-6, Leon Grapenthin wrote: >> >> I have written enough Clojure so that I can assure you that every few >> days when I type ^:private again I am still annoyed by it. Not every time, >> but probably every second or third time. >> >> Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you >> don't hit so often so you have to hit it right. On german keyboards, by the >> way, ^ is a much more annoying character to type. Then a colon, did I miss >> the colon? What did I want to do again? >> >> When prototyping an API ns its important to distinguish what is private >> and what isn't. If only I could just write def- without any overhead. >> >> First world aka best language problems, I know... >> >> But whats left for an enthusiast except bikeshedding? We both know that a >> JIRA discussion on this will not happen due to a lack of importance. And >> unless somebody manages to convince Rich, this feature won't happen. >> >> Fair enough. I'd consider myself a power user since 1.5.1 and value its >> conservative governance above every other kind. >> The "lets not start postfixing lots of macros with -" argument a good one >> in general and probably was a good one at the time. But not in this case >> because defn and def are the two most used and most elementary top level >> forms. >> >> This argument didn't convince anyone who has asked me about this. The >> counter argument goes "I don't want the - postfix for anything else, just >> for def because I use it a lot" -rightfully so. >> >> The lack of def- is just unnecessary typing overhead in lots of cases. It >> could be removed at the cost 5m on a beautiful day. I'd appreciate it :) >> >> On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev >> wrote: >>> >>> - Not that often. When I know for certain, I add ^:private. Not like >>> it's much more work. If I didn't know ahead of time, I would forget to add >>> the private flag in either case. >>> - Never. >>> - Can't recollect such an event. >>> - A few times. As far as I can tell, people appreciate the metadata >>> approach since it is unique and powerful. The lack of one particular >>> non-critical syntactic sugar is never an issue. >>> >>> I won't mind having def- as much as I don't mind not having it. Pretty >>> much the same as for defn- – Earth wouldn't stop turning if you had to type >>> defn ^:private once in a while. >>> >>> And while I agree with you that it would be somewhat useful, >>> bikeshedding only gets you so far. >>> >>> On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: - How many times do you just write (def ...) instead of (def ^:private .
Re: Why does the `def-` not exist?
We're not going to add def-. There is regret over even adding defn-, but we don't take things away... At one point all of the current metadata niceties didn't exist (used to be #^{:private true} some may recall) and defn- seemed worth doing I presume (pre-dates my involvementT). But then that was all simplified down to just ^:private and it's preferred to compose the pieces rather than copy N things. There used to be a slew of these in the old clojure-contrib (https://github.com/clojure/clojure-contrib/blob/master/modules/def/src/main/clojure/clojure/contrib/def.clj - but no def- !). How often do you def things anyway (much less private things)? On Monday, February 26, 2018 at 1:50:40 PM UTC-6, Leon Grapenthin wrote: > > I have written enough Clojure so that I can assure you that every few days > when I type ^:private again I am still annoyed by it. Not every time, but > probably every second or third time. > > Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you > don't hit so often so you have to hit it right. On german keyboards, by the > way, ^ is a much more annoying character to type. Then a colon, did I miss > the colon? What did I want to do again? > > When prototyping an API ns its important to distinguish what is private > and what isn't. If only I could just write def- without any overhead. > > First world aka best language problems, I know... > > But whats left for an enthusiast except bikeshedding? We both know that a > JIRA discussion on this will not happen due to a lack of importance. And > unless somebody manages to convince Rich, this feature won't happen. > > Fair enough. I'd consider myself a power user since 1.5.1 and value its > conservative governance above every other kind. > The "lets not start postfixing lots of macros with -" argument a good one > in general and probably was a good one at the time. But not in this case > because defn and def are the two most used and most elementary top level > forms. > > This argument didn't convince anyone who has asked me about this. The > counter argument goes "I don't want the - postfix for anything else, just > for def because I use it a lot" -rightfully so. > > The lack of def- is just unnecessary typing overhead in lots of cases. It > could be removed at the cost 5m on a beautiful day. I'd appreciate it :) > > On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev wrote: >> >> - Not that often. When I know for certain, I add ^:private. Not like it's >> much more work. If I didn't know ahead of time, I would forget to add the >> private flag in either case. >> - Never. >> - Can't recollect such an event. >> - A few times. As far as I can tell, people appreciate the metadata >> approach since it is unique and powerful. The lack of one particular >> non-critical syntactic sugar is never an issue. >> >> I won't mind having def- as much as I don't mind not having it. Pretty >> much the same as for defn- – Earth wouldn't stop turning if you had to type >> defn ^:private once in a while. >> >> And while I agree with you that it would be somewhat useful, bikeshedding >> only gets you so far. >> >> On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: >>> >>> - How many times do you just write (def ...) instead of (def ^:private >>> ...) because you are not sure whether you need the definition yet, want to >>> save effort, and then you forget to add ^:private later? >>> - How many times have you implemented def- yourself into your project >>> and then used only half of the time because you had to require and :refer >>> the thing from some util namespace which is just as annoying as typing >>> ^:private? >>> - How many times do you use autocomplete on some namespace and find >>> internals because their dev forgot ^:private? >>> - How many times in a year do you have to explain to a Clojure newbie >>> that there is defn- but no def-? >>> >>> IME the statistic strongly supports def- - and I don't see why it would >>> hurt. >>> Having def- in clojure.core will not magically result in having >>> defmacro- and defmulti- and xyz-. Its a false and the only counterargument >>> I have seen. >>> >>> It would be very useful, though. >>> >>> On Monday, February 26, 2018 at 1:44:27 PM UTC+1, Alexander Yakushev >>> wrote: Usually, it is better to use metadata rather than create an exponential explosion of names. Public/private is just one dimension, but you also have static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, macros, perhaps modified functions (like schema.core/defn). Cartesian product of those would be huge. defn- is an exclusion from the rule probably because it is used more often than others. On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: > > `defn-` => `defn` > 'def-` => `def` > -- You received this message beca
RE: Why does the `def-` not exist?
Personally, I just don't use private defs at all. Inevitably, you'll have to var-hack them during testing, so at some point I stopped doing so. Interesting. I pretty much never write a private function these days so I use defn but not defn- however, nearly all of my def’s are ^:private except in tests (where it’s just laziness – they could all be private) or examples (which are, again, often mostly laziness). So def- would save me a lot of typing and I’d even be happy if the default was private for def (and needed some ^:public metadata to override). But I know neither of those will happen so I just try to make it muscle-memory to always type ^:private after I type def! 😊 Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood From: clojure@googlegroups.com on behalf of Gary Trakhman Sent: Monday, February 26, 2018 12:03:27 PM To: clojure@googlegroups.com Subject: Re: Why does the `def-` not exist? If you're an emacs user, have you considered Yasnippet? It shouldn't be too hard to add to this: https://github.com/mpenet/clojure-snippets/tree/master/snippets/clojure-mode . Personally, I just don't use private defs at all. Inevitably, you'll have to var-hack them during testing, so at some point I stopped doing so. On Mon, Feb 26, 2018 at 2:50 PM Leon Grapenthin mailto:grapenthinl...@gmail.com>> wrote: I have written enough Clojure so that I can assure you that every few days when I type ^:private again I am still annoyed by it. Not every time, but probably every second or third time. Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you don't hit so often so you have to hit it right. On german keyboards, by the way, ^ is a much more annoying character to type. Then a colon, did I miss the colon? What did I want to do again? When prototyping an API ns its important to distinguish what is private and what isn't. If only I could just write def- without any overhead. First world aka best language problems, I know... But whats left for an enthusiast except bikeshedding? We both know that a JIRA discussion on this will not happen due to a lack of importance. And unless somebody manages to convince Rich, this feature won't happen. Fair enough. I'd consider myself a power user since 1.5.1 and value its conservative governance above every other kind. The "lets not start postfixing lots of macros with -" argument a good one in general and probably was a good one at the time. But not in this case because defn and def are the two most used and most elementary top level forms. This argument didn't convince anyone who has asked me about this. The counter argument goes "I don't want the - postfix for anything else, just for def because I use it a lot" -rightfully so. The lack of def- is just unnecessary typing overhead in lots of cases. It could be removed at the cost 5m on a beautiful day. I'd appreciate it :) On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev wrote: - Not that often. When I know for certain, I add ^:private. Not like it's much more work. If I didn't know ahead of time, I would forget to add the private flag in either case. - Never. - Can't recollect such an event. - A few times. As far as I can tell, people appreciate the metadata approach since it is unique and powerful. The lack of one particular non-critical syntactic sugar is never an issue. I won't mind having def- as much as I don't mind not having it. Pretty much the same as for defn- – Earth wouldn't stop turning if you had to type defn ^:private once in a while. And while I agree with you that it would be somewhat useful, bikeshedding only gets you so far. On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: - How many times do you just write (def ...) instead of (def ^:private ...) because you are not sure whether you need the definition yet, want to save effort, and then you forget to add ^:private later? - How many times have you implemented def- yourself into your project and then used only half of the time because you had to require and :refer the thing from some util namespace which is just as annoying as typing ^:private? - How many times do you use autocomplete on some namespace and find internals because their dev forgot ^:private? - How many times in a year do you have to explain to a Clojure newbie that there is defn- but no def-? IME the statistic strongly supports def- - and I don't see why it would hurt. Having def- in clojure.core will not magically result in having defmacro- and defmulti- and xyz-. Its a false and the only counterargument I have seen. It would be very useful, though. On Monday, February 26,
Re: Why does the `def-` not exist?
I don't see a huge problem with adding def- I think its omission relates to the mantra Encapsulation of information is folly. And thus its trying to discourage you from using private state and namespaces as classes? Maybe? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
If you're an emacs user, have you considered Yasnippet? It shouldn't be too hard to add to this: https://github.com/mpenet/clojure-snippets/tree/master/snippets/clojure-mode . Personally, I just don't use private defs at all. Inevitably, you'll have to var-hack them during testing, so at some point I stopped doing so. On Mon, Feb 26, 2018 at 2:50 PM Leon Grapenthin wrote: > I have written enough Clojure so that I can assure you that every few days > when I type ^:private again I am still annoyed by it. Not every time, but > probably every second or third time. > > Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you > don't hit so often so you have to hit it right. On german keyboards, by the > way, ^ is a much more annoying character to type. Then a colon, did I miss > the colon? What did I want to do again? > > When prototyping an API ns its important to distinguish what is private > and what isn't. If only I could just write def- without any overhead. > > First world aka best language problems, I know... > > But whats left for an enthusiast except bikeshedding? We both know that a > JIRA discussion on this will not happen due to a lack of importance. And > unless somebody manages to convince Rich, this feature won't happen. > > Fair enough. I'd consider myself a power user since 1.5.1 and value its > conservative governance above every other kind. > The "lets not start postfixing lots of macros with -" argument a good one > in general and probably was a good one at the time. But not in this case > because defn and def are the two most used and most elementary top level > forms. > > This argument didn't convince anyone who has asked me about this. The > counter argument goes "I don't want the - postfix for anything else, just > for def because I use it a lot" -rightfully so. > > The lack of def- is just unnecessary typing overhead in lots of cases. It > could be removed at the cost 5m on a beautiful day. I'd appreciate it :) > > On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev wrote: >> >> - Not that often. When I know for certain, I add ^:private. Not like it's >> much more work. If I didn't know ahead of time, I would forget to add the >> private flag in either case. >> - Never. >> - Can't recollect such an event. >> - A few times. As far as I can tell, people appreciate the metadata >> approach since it is unique and powerful. The lack of one particular >> non-critical syntactic sugar is never an issue. >> >> I won't mind having def- as much as I don't mind not having it. Pretty >> much the same as for defn- – Earth wouldn't stop turning if you had to type >> defn ^:private once in a while. >> >> And while I agree with you that it would be somewhat useful, bikeshedding >> only gets you so far. >> >> On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: >>> >>> - How many times do you just write (def ...) instead of (def ^:private >>> ...) because you are not sure whether you need the definition yet, want to >>> save effort, and then you forget to add ^:private later? >>> - How many times have you implemented def- yourself into your project >>> and then used only half of the time because you had to require and :refer >>> the thing from some util namespace which is just as annoying as typing >>> ^:private? >>> - How many times do you use autocomplete on some namespace and find >>> internals because their dev forgot ^:private? >>> - How many times in a year do you have to explain to a Clojure newbie >>> that there is defn- but no def-? >>> >>> IME the statistic strongly supports def- - and I don't see why it would >>> hurt. >>> Having def- in clojure.core will not magically result in having >>> defmacro- and defmulti- and xyz-. Its a false and the only counterargument >>> I have seen. >>> >>> It would be very useful, though. >>> >>> On Monday, February 26, 2018 at 1:44:27 PM UTC+1, Alexander Yakushev >>> wrote: Usually, it is better to use metadata rather than create an exponential explosion of names. Public/private is just one dimension, but you also have static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, macros, perhaps modified functions (like schema.core/defn). Cartesian product of those would be huge. defn- is an exclusion from the rule probably because it is used more often than others. On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: > > `defn-` => `defn` > 'def-` => `def` > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received th
Re: Why does the `def-` not exist?
I have written enough Clojure so that I can assure you that every few days when I type ^:private again I am still annoyed by it. Not every time, but probably every second or third time. Its just in the way of the prototyping typing (micro-)flow. SHIFT-6 you don't hit so often so you have to hit it right. On german keyboards, by the way, ^ is a much more annoying character to type. Then a colon, did I miss the colon? What did I want to do again? When prototyping an API ns its important to distinguish what is private and what isn't. If only I could just write def- without any overhead. First world aka best language problems, I know... But whats left for an enthusiast except bikeshedding? We both know that a JIRA discussion on this will not happen due to a lack of importance. And unless somebody manages to convince Rich, this feature won't happen. Fair enough. I'd consider myself a power user since 1.5.1 and value its conservative governance above every other kind. The "lets not start postfixing lots of macros with -" argument a good one in general and probably was a good one at the time. But not in this case because defn and def are the two most used and most elementary top level forms. This argument didn't convince anyone who has asked me about this. The counter argument goes "I don't want the - postfix for anything else, just for def because I use it a lot" -rightfully so. The lack of def- is just unnecessary typing overhead in lots of cases. It could be removed at the cost 5m on a beautiful day. I'd appreciate it :) On Monday, February 26, 2018 at 6:52:51 PM UTC+1, Alexander Yakushev wrote: > > - Not that often. When I know for certain, I add ^:private. Not like it's > much more work. If I didn't know ahead of time, I would forget to add the > private flag in either case. > - Never. > - Can't recollect such an event. > - A few times. As far as I can tell, people appreciate the metadata > approach since it is unique and powerful. The lack of one particular > non-critical syntactic sugar is never an issue. > > I won't mind having def- as much as I don't mind not having it. Pretty > much the same as for defn- – Earth wouldn't stop turning if you had to type > defn ^:private once in a while. > > And while I agree with you that it would be somewhat useful, bikeshedding > only gets you so far. > > On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: >> >> - How many times do you just write (def ...) instead of (def ^:private >> ...) because you are not sure whether you need the definition yet, want to >> save effort, and then you forget to add ^:private later? >> - How many times have you implemented def- yourself into your project and >> then used only half of the time because you had to require and :refer the >> thing from some util namespace which is just as annoying as typing >> ^:private? >> - How many times do you use autocomplete on some namespace and find >> internals because their dev forgot ^:private? >> - How many times in a year do you have to explain to a Clojure newbie >> that there is defn- but no def-? >> >> IME the statistic strongly supports def- - and I don't see why it would >> hurt. >> Having def- in clojure.core will not magically result in having defmacro- >> and defmulti- and xyz-. Its a false and the only counterargument I have >> seen. >> >> It would be very useful, though. >> >> On Monday, February 26, 2018 at 1:44:27 PM UTC+1, Alexander Yakushev >> wrote: >>> >>> Usually, it is better to use metadata rather than create an exponential >>> explosion of names. Public/private is just one dimension, but you also have >>> static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, >>> macros, perhaps modified functions (like schema.core/defn). Cartesian >>> product of those would be huge. >>> >>> defn- is an exclusion from the rule probably because it is used more >>> often than others. >>> >>> On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: `defn-` => `defn` 'def-` => `def` >>> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
- Not that often. When I know for certain, I add ^:private. Not like it's much more work. If I didn't know ahead of time, I would forget to add the private flag in either case. - Never. - Can't recollect such an event. - A few times. As far as I can tell, people appreciate the metadata approach since it is unique and powerful. The lack of one particular non-critical syntactic sugar is never an issue. I won't mind having def- as much as I don't mind not having it. Pretty much the same as for defn- – Earth wouldn't stop turning if you had to type defn ^:private once in a while. And while I agree with you that it would be somewhat useful, bikeshedding only gets you so far. On Monday, February 26, 2018 at 7:17:05 PM UTC+2, Leon Grapenthin wrote: > > - How many times do you just write (def ...) instead of (def ^:private > ...) because you are not sure whether you need the definition yet, want to > save effort, and then you forget to add ^:private later? > - How many times have you implemented def- yourself into your project and > then used only half of the time because you had to require and :refer the > thing from some util namespace which is just as annoying as typing > ^:private? > - How many times do you use autocomplete on some namespace and find > internals because their dev forgot ^:private? > - How many times in a year do you have to explain to a Clojure newbie that > there is defn- but no def-? > > IME the statistic strongly supports def- - and I don't see why it would > hurt. > Having def- in clojure.core will not magically result in having defmacro- > and defmulti- and xyz-. Its a false and the only counterargument I have > seen. > > It would be very useful, though. > > On Monday, February 26, 2018 at 1:44:27 PM UTC+1, Alexander Yakushev wrote: >> >> Usually, it is better to use metadata rather than create an exponential >> explosion of names. Public/private is just one dimension, but you also have >> static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, >> macros, perhaps modified functions (like schema.core/defn). Cartesian >> product of those would be huge. >> >> defn- is an exclusion from the rule probably because it is used more >> often than others. >> >> On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: >>> >>> `defn-` => `defn` >>> 'def-` => `def` >>> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
- How many times do you just write (def ...) instead of (def ^:private ...) because you are not sure whether you need the definition yet, want to save effort, and then you forget to add ^:private later? - How many times have you implemented def- yourself into your project and then used only half of the time because you had to require and :refer the thing from some util namespace which is just as annoying as typing ^:private? - How many times do you use autocomplete on some namespace and find internals because their dev forgot ^:private? - How many times in a year do you have to explain to a Clojure newbie that there is defn- but no def-? IME the statistic strongly supports def- - and I don't see why it would hurt. Having def- in clojure.core will not magically result in having defmacro- and defmulti- and xyz-. Its a false and the only counterargument I have seen. It would be very useful, though. On Monday, February 26, 2018 at 1:44:27 PM UTC+1, Alexander Yakushev wrote: > > Usually, it is better to use metadata rather than create an exponential > explosion of names. Public/private is just one dimension, but you also have > static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, > macros, perhaps modified functions (like schema.core/defn). Cartesian > product of those would be huge. > > defn- is an exclusion from the rule probably because it is used more > often than others. > > On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: >> >> `defn-` => `defn` >> 'def-` => `def` >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Why does the `def-` not exist?
Usually, it is better to use metadata rather than create an exponential explosion of names. Public/private is just one dimension, but you also have static/non-static, dynamic/non-dynamic, etc. Then you have functions, vars, macros, perhaps modified functions (like schema.core/defn). Cartesian product of those would be huge. defn- is an exclusion from the rule probably because it is used more often than others. On Monday, February 26, 2018 at 10:58:43 AM UTC+2, Promise. wrote: > > `defn-` => `defn` > 'def-` => `def` > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Why does the `def-` not exist?
`defn-` => `defn` 'def-` => `def` -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.