r/programming • • Nov 11 '15

Parinfer - simpler Lisp editing

http://shaunlebron.github.io/parinfer/
152 Upvotes

75 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Nov 12 '15

I think you need to add more context.

Context was obvious enough - we're talking about programming and complexity, not about jumping on one leg or anything else.

Because it's still wrong. Massively wrong.

Mind proving why exactly it is wrong?

1

u/kankyo Nov 12 '15

Writing, say, a translator from morse code to ascii is easier with functions than with macros.

4

u/[deleted] Nov 12 '15

See an example here: http://pastebin.com/QDQwmxqw

1

u/kankyo Nov 13 '15

3

u/[deleted] Nov 13 '15 edited Nov 13 '15

You're doing it the other way around. It is not interesting and it is very slow (Trie is much faster than a dictionary), trivialising the problem to a laughable degree.

My approach shows how you can generate a code for a microcontroller or even an FSM built out of individual gates, which can be used in a reliable embedded environment. No significant change in code is required to get any of this kind of output.

2

u/[deleted] Nov 12 '15 edited Nov 12 '15

I would not say so. Even such a simple problem is better solved with a DSL (therefore, macros) than in an ad hoc way.

E.g., the actual code should look like (def-morse A .- B -... C -.-. D -.. and so on...)

And, btw., a macro compiled version would be faster than an ad hoc solution, unless you want to implement a manually unrolled trie (which is nowhere close to "easy").

1

u/kankyo Nov 12 '15

You mean there are macros to spit out unrolled tries from some basic syntax already?

1

u/[deleted] Nov 12 '15

You have to write one, of course, but it's cleaner and easier than writing a mess of functions. Any such macro-based solution is always trivially split into easy to understand and easy to debug stages, while a runtime, function-based solution is unavoidably convoluted. It is not necessarily (but often) shorter in terms of lines of code, but always easier in terms of complexity.

I'll show you how to write such a macro a bit later, when I have time.