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

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.

-----