~technomancy/fennel

Reintroduce ~= as an alias for not=. v1 PROPOSED

I guess really this is a question about whether we should treat the ~
character as reserved. If we want to do that, we should remove it from
the list in issymbolchar which allows it to be part of symbols, but if
we leave issymbolchar alone, then I think it would be better to
reintroduce this alias, because the original rationale for removing it
no longer applies.

Do we have any possible candidates for syntax that will require
reserving ~ for the future?

-Phil
(Resending this to the list, sorry Phil for the duplicate message)

Phil Hagelberg <phil@hagelb.org> writes:
> I guess really this is a question about whether we should treat the ~
> character as reserved. If we want to do that, we should remove it from
> the list in issymbolchar which allows it to be part of symbols, but if
> we leave issymbolchar alone, then I think it would be better to
> reintroduce this alias, because the original rationale for removing it
> no longer applies.
> 
> Do we have any possible candidates for syntax that will require
> reserving ~ for the future?
> 
> -Phil
I believe part of the rationale was to be able to have a character
reserved by the compiler which would allow us to add special forms by
any name we wanted without ever breaking extant fennel code in doing
so. However, given that ~ is no longer unquote and the removal of ~= is
a particularly annoying breaking change (which I can confirm
personally), perhaps it's better to do one of the following:

- Abandon the idea of a reserved compiler character or sigil, and just
  add globally-bound symbols when we create new special forms or
  built-in macros. We already do this without much trouble, and we could
  potentially version this map of names-to-builtins so that users can
  use newer compilers with unmodified code by telling the compiler to
  use the builtin names from an older version. They wouldn't be able to
  use newer builtins, but they could still benefit from other
  improvements to the compiler and tool suite.

- Use a less common character that won't result in as much breakage. As
  a shorthand for unquote-splicing - aka ,(unpack ...) - hardly seems
  necessary, @ seems like a good candidate.

Either way, I strongly agree with adding ~= back in as an undocumented
alias. Early users of Fennel have almost certainly used the "not equal"
function already, and every single one who has will have to fix their
code if this change is released.

- Benaiah
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~technomancy/fennel/patches/7821/mbox | git am -3
Learn more about email & git

[PATCH] Reintroduce ~= as an alias for not=. Export this patch

This makes it so that there are no breaking changes for 0.3.0 outside
the macro system, which is documented as being in flux.

Originally we removed ~= because we were going to make ~ a reserved
character in order to use it for unquote, like Clojure. But in the end
we decided to use commas for unquoting instead.
---
 changelog.md | 8 +++-----
 fennel.lua   | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/changelog.md b/changelog.md
index e34b03e..fd0e1da 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,8 +2,8 @@
 
 ## 0.3.0 / ??
 
-* **Disallow** non-gensym identifiers in backtick/macros.
-* Support `x#` syntax for auto-gensym inside backtick.
+* **Disallow** non-gensym identifiers in backtick/macros
+* Support `x#` syntax for auto-gensym inside backtick
 * Fix a bug in `lambda` arity checks when using destructuring
 * Support `:one-line` output in fennelview
 * Add `--eval` argument to command-line launcher
@@ -16,15 +16,13 @@
 * Improve code generation for `if` expressions in many situations
 * Alias `#` special with `length`
 * Replace `@` (unquote) with `,`; comma is **no longer** whitespace
-* **Disallow** `~` in symbols
-* **Remove** `~=` special; use `not=` instead
 * Add `hashfn` and `#` reader macro for shorthand functions like `#(+ $1 $2)`
 * Add `macro` to make defining a single macro easier
 * Add `(comment)` special which emits a Lua comment in the generated source
 
 ## 0.2.1 / 2019-01-22
 
-* Add `not=` as an alias for `~=`
+* Make `~=` into an alias for `not=`
 * Fix a bug with `in-scope?` which caused `match` outer unification to fail
 * Fix a bug with variadic `~=` comparisons
 * Improve error reporting for mismatched delimiters
diff --git a/fennel.lua b/fennel.lua
index f68a38e..0013081 100644
--- a/fennel.lua
+++ b/fennel.lua
@@ -1719,6 +1719,7 @@ end
 defineUnarySpecial('not', 'not ')
 defineUnarySpecial('length', '#')
 SPECIALS['#'] = SPECIALS['length']
+SPECIALS['~='] = SPECIALS['not=']
 
 -- Save current macro scope
 local macroCurrentScope = GLOBAL_SCOPE
-- 
2.11.0
I guess really this is a question about whether we should treat the ~
character as reserved. If we want to do that, we should remove it from
the list in issymbolchar which allows it to be part of symbols, but if
we leave issymbolchar alone, then I think it would be better to
reintroduce this alias, because the original rationale for removing it
no longer applies.

Do we have any possible candidates for syntax that will require
reserving ~ for the future?

-Phil
View this thread in the archives