Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Kyle I S Harrington
@kephale
ok, I'm still understanding the ways of benefiting from Hissp's lambda implementation. that said i think i prefer using apply over directly using the reader macro with star unpacking, just for readability
gilch
@gilch
Given itertools.starmap and star unpacking, I don't recall ever missing apply in Python.
gilch
@gilch
Another advantage of star unpacking is that you can do it more than once in the same call, like (foo bar : :* spam :? baz :* eggs).
Kyle I S Harrington
@kephale
how do you make a list of strings? ["a","b"] doesn't work, although [1,2] does
gilch
@gilch
['a','b']
Collection atoms are injections, so they use Python syntax.
There are a lot of examples in the quick start: https://hissp.readthedocs.io/en/latest/lissp_quickstart.html
See the ;;;; COLLECTIONS section.
[\"a\",\"b\"] also works, but single quotes are easier.
gilch
@gilch
(list '(a b)) would also work, but beware of munging when using symbols as strings this way.
You might expect (list '("a" "b")) to also work, but that has to compile the quotes in to distinguish them from identifiers, resulting in ["('a')", "('b')"].
The right way to do that is (list `(,"a" ,"b")).
gilch
@gilch
Unlike the collection atoms, you can interpolate runtime values this way.
If you're doing anything complicated, like nesting these, or using them in macro templates, the overhead of managing the unquotes and the extra set of parentheses can make this difficult.
In that case, I'd recommend using helper functions.
gilch
@gilch
If you like Python's default collections, that would mean the entuple, endict and enlist helpers demonstrated in the quick start.
You could also define an enset in a very similar way to enlist.
If you'd rather have collections that work more like Clojure, I'd recommend installing pyrsistent and using their helpers.
gilch
@gilch
They implement the appropriate collection protocols, so they mostly just work with other Python libraries, and in case they don't, you can thaw.
Kyle I S Harrington
@kephale
one thing i keep seeing over and over, i think it is coming from using nested macros "SyntaxError: Bad space: '\t'"
a minimal example is:
this throws the error
(.upper (let (mystr "asdf")
          (operator..add mystr "ghj")))
this doesnt:
(.upper (let (mystr "asdf") (operator..add mystr "ghj")))
gilch
@gilch
Tab characters are not allowed for indentation in Lissp. Use spaces.
Kyle I S Harrington
@kephale
ah ok, i was just using the default behavior of emacs and dont really care about the difference
great that it is an easy fix
gilch
@gilch
I suppose I could make that error message clearer.
Tabs are allowed in strings, they just aren't whitespace.
Kyle I S Harrington
@kephale
is there a technical reason?
gilch
@gilch
Standard tab stops are technically supposed to be equivalent to 8 spaces, when used as indentation. But you more often see them set to 2 or 4, and 1 or 3 is not that rare either. Because indentation is so important for legibility in Lisp, and for Parinfer to work, bad tabstop settings can cause a lot of issues.
Kyle I S Harrington
@kephale
i see
so legibility/parainfer, and not something like reader macro clashes or things along those lines
gilch
@gilch
Especially when working on teams, where members might be editing using different software.
Disallowing them altogether prevents all these issues, and also eliminates a bunch of special cases tooling would otherwise have to deal with.
You can see the regex for tokenizing Lissp in hissp.reader.
gilch
@gilch
It would not be technically difficult to match \s+ as whitespace, instead of the current [ \n]+.
But disallowing tabs for indents was intentional.
Kyle I S Harrington
@kephale
ok, to be clear i don't care at all, but default emacs config (at least on ubuntu) seems to use tabs. so to me it just seems like another config hurdle for new users
gilch
@gilch
Default emacs config is pretty dated. It's probably still using the traditional 8-space tabstops. Parinfer might be using 2 spaces.
I should make the error message clearer, and maybe give it a mention in the docs, since standard practice for most other languages is to treat tabs as whitespace.
Kyle I S Harrington
@kephale
that would be good
i'm still not 100% sold but again i'm pretty indifferent once i change my settings
i understand your reasoning, and maybe it lines up with the forced indenting style of python
but since tooling isnt provided for hissp or default configurations
it does seem like an extra hurdle for new users
gilch
@gilch
Looks like Parinfer is configurable, so it might depend on which plugin.
gilch
@gilch
I agree it's a hurdle for new users. I still don't think that allowing tabs is worth it, as it is just a config change. Once and done. Once Lissp is more stable, maybe it can have dedicated tooling that handles this. Then they just install the plugin for their editor and it configures that for them.
gilch
@gilch
I'm hoping to get the next release out some time this weekend. At the rate I'm going, I feel optimistic.
Kyle I S Harrington
@kephale
huzzah!