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

#; as discard syntax instead of #_ #1639

Closed
pyx opened this issue Jun 13, 2018 · 8 comments
Closed

#; as discard syntax instead of #_ #1639

pyx opened this issue Jun 13, 2018 · 8 comments

Comments

@pyx
Copy link
Contributor

pyx commented Jun 13, 2018

I didn't know this feature as it's not mentioned in documentation until I saw #1636
It's hard to search on #_ so I bisected the repository and found out that it's been added quite a while 203965d, since last Aug.

But still, I suggest using #; as descard syntax instead of #_.

Rationale

  • ; is the comment character (my wording maybe wrong) already
  • #; is being used in scheme (SRFI-62), some implementations, Chichen, Guile
  • free up _ (I know it can be shadowed, BTW) as user defined tag macro, in the case of i18n, function gettext is most likely imported as _, adding (_ ...) to every single string to existing code base is no fun, users can then define a tag macro, aptly named #_, as
(deftag _ [str]
  `(_ ~str))

;; using new import syntax #1614

(require .macro [_])
(import gettext [gettext :as _])

...

(defn run []
  (message-box #_ "hello world"))

and be done with it.

The cost of rename should be minimal, since it's not mentioned in documentation, I doubt many people using it currently, rename should not cause much trouble, while ; as tag macro is impossible to define by users, so nobody using it.

@pyx
Copy link
Contributor Author

pyx commented Jun 13, 2018

Edit: I was unaware of this section http://docs.hylang.org/en/stable/language/api.html#discard-prefix , it is documented already. I am sorry.

@refi64
Copy link
Contributor

refi64 commented Jun 13, 2018

I think the idea behind using #_ is that it behaves less like a normal comment and more like a compile-time version of _ = xyz in that it discards something.

@pyx
Copy link
Contributor Author

pyx commented Jun 13, 2018

I sort of understand the reason _ being chosen in the first place, originated from a way to signify the value is of no importance, which in term, borrowed from ML languages.

In both python and strict MLs (OCaml for example), the expression being bound to _ is evaluated, then the result is discarded, while #_ as it is now, the next expression is discarded right away, not even being turned into AST, so I believe, in this regard, #; is actually telling what really happened behind the scenes.

@gilch
Copy link
Member

gilch commented Jun 17, 2018

#_ is the discard prefix used by Clojure and EDN, which is where we got the idea from in the first place. #; would have been a fair choice for Clojure, I suppose, but we've mostly been following Clojure's syntactic conventions, not Scheme's.

@refi64
Copy link
Contributor

refi64 commented Jun 17, 2018

#; would also be harder for editors to highlight. Not too much more difficult, but a bit.

@pyx
Copy link
Contributor Author

pyx commented Jun 18, 2018

So this is an official "no", am I right?
If so, I will close this.

@gilch
Copy link
Member

gilch commented Jun 19, 2018

Well, officially, I think it takes three core members willing to revert a change for an absolute veto, but considering the lack of interest so far, the chances of this change getting approved don't look so good.

Clojure gives a stronger precedent for the current syntax, so I don't find the Scheme argument very convincing.

Currently _ is an alias for -, which is the shadow subtraction function, so you shouldn't import gettext by that name anyway. (We might change this #1635.) We also changed the repl history variables from _ to *1 *2 *3 like Clojure.

This does seem like a good use case for tag macros. But you still have a lot of options. I think __ would work, and #__ should work as a tag macro too. You could also just import gettext and do any number of other tags.

(import gettext[gettext])

 (deftag "18" [str]
  `(gettext ~str))

(defn run []
  (message-box #18"hello world"))

@pyx
Copy link
Contributor Author

pyx commented Jun 19, 2018

Thanks for the clarification. I might use #tr or #trs for gettext then, and #i18n for extra fun :). I will close this at the moment. In case someone else bring this up again, I will still be voting for #;

@pyx pyx closed this as completed Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants