masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
137 stars 14 forks source link

Rethink the examples in examples/ #194

Open masak opened 8 years ago

masak commented 8 years ago

I was really happy when we finally could close #54. Opened in October, closed it in March. (And finally got all the tests in place in July.)

But I find that directory needs to live up to a higher standard nowadays. It should be about macros, (maybe) slangs, grammar hacking, language extensions, and the other things that makes 007 unique. It shouldn't just be examples that could be written in any half-competent ALGOLoid, no matter how nice they may look in 007.

Basically, I don't want people to go to the examples/ directory and be underwhelmed.

Let's go through them. Anything that's just "ordinary code" takes the cut.

Uh. But I also don't want just two examples in that directory.

So how about we also introduce new conforming examples with each one we remove? Yes, that'll make this issue decidedly non-low-hanging fruit. But I think it'll be worth it. It's a high ambition, but one we can comfortably aim for. There's plenty of macro ideas in the issue queue that we want to try anyway.

masak commented 8 years ago

I just want to add, for sentimentality, that once it did feel amazing that we had all those code examples. But 007 has basically outgrown that. The previously fantastic is now the mundane. And that's a good thing.

masak commented 7 years ago

I think two of the most realistic macro ideas to include in the examples would be #122, #152 and #203. All of those are definitely tied to real use cases.

masak commented 7 years ago

Oh, and if I were to dream a bit, #116 would be really nice to have in examples/. To the point where it would almost be worth two old example scripts. :smile:

But the thing is, 007 as interpreted through Rakudo is still too slow to make an effective demonstration of #116. So we'd need either a JavaScript backend (#166), or something similarly fast and impressive.

masak commented 7 years ago

I see I haven't mentioned #176 as an example I want in examples/. It definitely has a place there.

Yay! I love how this issue is now pushing the roadmap places. :smile:

masak commented 7 years ago

Heck, a swap macro! I just tried to write a version of this working Perl 6 version, but...

$ bin/007 -e='macro swap(a, b) { return quasi { my temp = {{{a}}}; {{{a}}} = {{{b}}}; {{{b}}} = temp; None } }; my w = 5; my z = 10; swap(w, z); say([w, z])'
Missing quasi
[...]

Dang, we really need to clean up our act with #10 and better parse errors in general. I want really good line/column numbers, and an arrow/⏏ into the place that's wrong.

As I tried to reduce this parse error, I ran into a simpler variant of #212. *sigh*

But anyway. swap macro. That takes our count to 6 macro examples. Since I said #116 is worth two old examples, we can actually throw out all the 7 old ones once we have those 6 new ones.

masak commented 7 years ago

(comment about slangs moved out to its own issue)

masak commented 7 years ago

Here, let me summarize the macro examples that we want to implement to replace the old examples. I'll try to put them in order, most desirable first:

The ones marked ❦ need #214 to land in order to work non-buggily. The ones marked ♁ need is parsed of #177 fame.

masak commented 7 years ago

Also #202 and #215. My, there's no dearth of good macro examples to implement! (In my copious spare time, no less.) I would say importance-wise, these two slot in right above SEND MORE MONEY above.

masak commented 7 years ago

Also #158 since it nicely showcases nested contextual macros.

masak commented 6 years ago

I think #229 (Elvis safe navigation operator) deserves to go on this list as well.

masak commented 5 years ago

I know this issue isn't really accepting any more nominations... But as I'm thinking about #481 and what I'd like to have ready by then to talk about, I realize #186 would be a really nice, small example.

masak commented 3 years ago

Added a "currently blocked" label, because all the remaining examples are waiting on #177.