~andreyorst

Moscow

https://andreyorst.gitlab.io/

I love Lisp and text editors!

Recent activity

[PATCH v2] fix ?. behavior introduced in 18c6fcf and fix tests not being ran 3 days ago

From Andrey Listopadov to ~technomancy/fennel

The change introduced in 18c6fcf made ?. behave the same as .
This was not caught by the tests, because tests were not ran at all,
because "expected" result was nil, and assigning nil to table key
effectively removes that key from the table, thus making tests
completely ignored. I've noticed this and fixed in some other tests in
core.fnl as well.
---
 src/fennel/macros.fnl |  8 +++---
 test/core.fnl         | 30 +++++++++----------
 test/macro.fnl        | 67 ++++++++++++++++++++++---------------------
 3 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/src/fennel/macros.fnl b/src/fennel/macros.fnl
index fd59a05..5f35919 100644
[message trimmed]

[PATCH] fix ?. behavior introduced in 18c6fcf and fix tests not being ran 3 days ago

From Andrey Listopadov to ~technomancy/fennel

The change introduced in 18c6fcf made ?. behave the same as .
This was not caught by the tests, because tests were not ran at all,
because "expected" result was nil, and assigning nil to table key
effectively removes that key from the table, thus making tests
completely ignored.

I've updated the tests to use `type` special around the ones that
expect `nil` as a result, and changed `nil` to `:nil` thus ensuring
that tests still return exactly `nil`. Maybe test suite should use
sequential table of sequential tables instead of associative table
with tests as keys? This will give deterministic order for tests and
will also make the change above irrelevant?
---
 src/fennel/macros.fnl |  8 ++++----
[message trimmed]

[PATCH] ensure that __fennelview has higher priority than :prefer-colon? 5 days ago

From Andrey Listopadov to ~technomancy/fennel

When __fennelview calls view function with last argument set to true
the string is printed as colon string, when possible.  When the last
argument is false, string is always printed in double quotes.  When
the last argument is omitted, value of :prefer-colon? key is used.

I've also used forward declaration for internal pp function instead of
defining it in a table, and fixed docstring, as per 0e8efe6 the
docstring mentions :colon-strings? instead of :prefer-colon?  option.
---
 fennelview.lua      | 64 ++++++++++++++++++++++----------------
 src/fennel/view.fnl | 76 +++++++++++++++++++++++++--------------------
 test/core.fnl       | 13 +++++++-
 3 files changed, 91 insertions(+), 62 deletions(-)
[message trimmed]

[PATCH] fix match not handling false pattern correctly 6 days ago

From Andrey Listopadov to ~technomancy/fennel

---
 src/fennel/macros.fnl | 6 ++++--
 test/macro.fnl        | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/fennel/macros.fnl b/src/fennel/macros.fnl
index b78dad0..ec9f4c7 100644
--- a/src/fennel/macros.fnl
+++ b/src/fennel/macros.fnl
@@ -369,8 +369,10 @@ introduce for the duration of the body if it does match."
        seconds []
        res []]
    (for [i 1 (length seq) 2]
      (table.insert firsts (or (. seq i) 'nil))
[message trimmed]

[PATCH] add nil-safe table lookup operator 7 days ago

From Andrey Listopadov to ~technomancy/fennel

This patch adds new ?. operator. This operator can be used to do
nested table lookup in a nil-safe manner of -?> and -?>>
operators. This means that if any of subsequent keys do not exist,
this operator will short-circuit to nil value:

(local t {:a {:b [:c :d {:e {:f 42}} :g]}})

(?. t :a :b 3 :e :f) ; 42
(?. t :a :b 5 :e :f) ; nil, because there's only 4 elements in vector

Note that the implementation is not what we've discussed
before. Instead I've chosen mostly the same approach as for -?>>
macro, which does repeated recursion expansion for each key lookup
until amount of keys exhausts. This way there's no iteration, and we
[message trimmed]

Re: [PATCH v2] implement new prefix syntax for match macro 7 days ago

From Andrey Listopadov to ~technomancy/fennel

> After I applied this I realized we can't use table.pack here because it
> doesn't exist in older Lua versions.

oh, wasn't aware that table.pack is a new thing.

> When they look like they have nil in them,
> they actually have a symbol named nil.

BTW I've saw (= :nil (tostring pattern)) in the code of
src/fennel/macros.fnl at line 294. AST nils can't be compared to `nil
or is it just an oversight?


-Andrey

[PATCH v2] implement new prefix syntax for match macro 8 days ago

From Andrey Listopadov to ~technomancy/fennel

New syntax replaces and extend old question mark `?' based guards with
prefix `where' guards and optional pattern ORing with `or' special
form.

Current implementation uses transformation from new syntax into old
match syntax, and passes the result to an old implementation of match*
macro.  I've found this way much easier to integrate and also maintain
new syntax (like if we will decide to allow `or' outside of where we
will need to add one additional line to current implementation).
Incorporating new syntax into old macro implementation proven to
result in quite ugly code, that IMO will be hard to understand and
maintain in the future.

I've added tests for the new syntax, and ensured that all old tests
[message trimmed]

[PATCH] implement new prefix syntax for match macro (without transformation) 9 days ago

From Andrey Listopadov to ~technomancy/fennel

New syntax replaces and extend old question mark `?' based guards with
prefix `where' guards and optional pattern ORing with `or' special
form.

This patch begs to be refactored, but I've understood that I couldn't
come up with a more clear implementation for match macro. Basically I
had to convert all `(values condition bindings)` to `[[condition
bindings]]` data structures, in order to have uniform iteration over
those in the final construction phase. I don't like this, as it adds
too much nesting, and I would personally vote for the other patch I've
sent to the list a bit earlier this day, which uses much more clear
approach of transforming new syntax into old sytax first, and then
using well tested match* on the transformation result.
[message trimmed]

[PATCH] implement new prefix syntax for match macro 9 days ago

From Andrey Listopadov to ~technomancy/fennel

New syntax replaces and extend old question mark `?' based guards with
prefix `where' guards and optional pattern ORing with `or' special
form.

Current implementation uses transformation from new syntax into old
match syntax and passes the result to old implementation of match*
macro.  I've found this way much easier to integrate and also maintain
new syntax (like if we will decide to allow `or' outside of where we
will need to add one additional line to current implementation).
Incorporating new syntax into old macro implementation proven to
result in quite ugly code, that IMO will be hard to understand and
maintain in the future.

I've added tests for the new syntax, and ensured that all old tests
[message trimmed]

Re: nil-safe nested table access operator 12 days ago

From Andrey Orst to ~technomancy/fennel

> Overall it seems good. However, making it take keys in a table seems
> somewhat strange to me; it seems to break the parallelism with the
> existing dot operator. I guess the advantage is that it lets you avoid
> an `or` call?

By making such function take fixed amount of argument at any time, and
specifying not-found value, we create functional interface. For
example, in Cljlib I have this as a get-in function, which can be used
like this:

    >> (mapv get-in [{:a {:b :val}} {:c [1 2]}] [[:a :b] [:c 10]] [:no-val 10])
    ["val" 10]

This can't be done so easilly with variadic function. But this