Arc Forumnew | comments | leaders | submitlogin
1 point by rocketnia 4857 days ago | link | parent

I prefer having 'aif be a special case of 'iflet too. The change you've made would only come up every so often. It might break some code that uses 'iflet for destructuring and the tests some other condition if that fails (whose result can't be destructured), but that's easy enough to fix.

For Penknife I've been thinking about something a bit different:

  [itif x
    do-something-with.it
   ifdecap first rest lst
    [do-something-with first rest]
   iflet result foo.bar
    baz.result
   do do-something-else.]
In this in-progress draft, every if-like construct parses its elses using the same utility. The point is to let them work together better while making the indentation less controversial and confusing than it is in Arc. The downside so far is that every single unconditional else needs a 'do in front of it to look nice, which feels a bit like (cond ((#t ...))).


1 point by akkartik 4857 days ago | link

"It might break some code that uses 'iflet for destructuring and the tests some other condition if that fails (whose result can't be destructured).."

Ah, destructured args!

https://github.com/akkartik/wart/commit/9cb777987467bedf4446...

Thanks for the bug report! :)

-----

1 point by akkartik 4857 days ago | link

ifdecap?

-----

1 point by rocketnia 4857 days ago | link

Penknife's version of (iflet (a . b) x ...) is [ifdecap a b x ...]. There's no destructuring yet, not to mention that Penknife has no notion of a dotted list.

I called 'ifdecap "ifpair" at one point, but I want it to be extensible, with a clear metaphor of first and rest rather than left and right.

-----

1 point by akkartik 4857 days ago | link

Ok, but why decap? Just a random pronounceable name for something low-level you didn't want to use a good name for?

-----

1 point by rocketnia 4857 days ago | link

Can you think of a better one? XD This isn't supposed to be that low-level. I'm working on the Penknife core from a top-down view right now, and I've considered having all argument lists decompose using ifdecap just so that a function can be applied to a user-defined type of list (which might support a user-defined kind of destructuring, for instance; think keyword args).

-----

1 point by akkartik 4857 days ago | link

I wasn't expressing dislike but curiosity. How did you end up with that name? Does it stand for 'decompose a pair'?

-----

1 point by rocketnia 4857 days ago | link

Lol. XD It's short for "if-decapitate."

Come to think of it, ifdecap is a bit paradoxical.... If it's used to destructure argument lists, then it'll be recursive upon itself over and over and probably never get anywhere. (It needs to return two values somehow, which means either the caller or a CPS-style callback will need to destructure those values. I don't plan to look for a multiple-value-return-esque solution.) I guess the built-in argument list type will need some kind of hardwired treatment just like the built-in function type.

-----