Problems expanding (++ "abcd" rest)

11 views
Skip to first unread message

Robert Virding

unread,
Jul 16, 2015, 8:11:49 PM7/16/15
to lisp-flavo...@googlegroups.com
++ is a macro. It would originally expand (++ "abcd" rest) to(cons 97 (cons 98 (cons 99 (cons 100 rest))) which is correct, quite reasonable and also allowed it to be used in patterns. However there was one serious problem with this, if the literal string was long then it would really slow the compiler down. A user was getting compile times of 5-10 mins for a reasonably sized file but with much appending of strings.

So that expansion went. Which was a shame because it is practical to use in patterns. It now expands to (call 'erlang '++ "abcd" rest). I have two suggestions to allow it in patterns, both hacky:

- Allow the call to erlang:++ expansion in patterns and at compile time expand it to cons. This would work even if it does add a special case.
- Do the expansion using cons if the literal string is "short". This would work as well and probably be enough to catch the pattern cases, but you wouldn't be sure.

So both feel a bit hacky and I don't know which one, if any, to use.

A third solutions would be to have a different macro which always expands to the cons version. Or a fourth alternative have ++ as a special form and do the expansion at compile time. These also feel hacky.

Anyway, food for thought,

Robert



Duncan McGreggor

unread,
Jul 17, 2015, 2:13:53 PM7/17/15
to lisp-flavo...@googlegroups.com
Robert, do you know which of the proposed hacks would have overall better performance? Or is that something that really requires testing compilation times once implemented...?

d

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-e...@googlegroups.com.
To post to this group, send email to lisp-flavo...@googlegroups.com.
Visit this group at http://groups.google.com/group/lisp-flavoured-erlang.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages