PratchettLovesYou / Issues

An issue-tracker for the Paws language (as opposed to any particular implemenation.)
2 stars 0 forks source link

`branch[]` is nearly useless for cloning oneself #14

Open devyn opened 10 years ago

devyn commented 10 years ago

This doesn't work because the caller of the third call to stage was given as this Execution, and thus that partially-applied stage remains on the stack after we branch ourselves. stage then attempts to return to us, when really we want it to return to our new branch. So, no looping occurs.

infrastructure execution stage[]
  [infrastructure affix[] [locals]] [infrastructure empty[]];

infrastructure execution stage[]
  [infrastructure set[]
    [infrastructure get[] [locals] [infrastructure length[] [locals]]]

    1] self.portrait;

infrastructure execution stage[]
  [infrastructure set[]
    [infrastructure get[] [locals] [infrastructure length[] [locals]]]

    2] [infrastructure execution branch[] []];

self.portrait [infrastructure execution branch[] [self.portrait]]
devyn commented 10 years ago

Possible solution: current branch[] becomes clone[], and new branch[] clones the caller and advances the clone.

Rather than the old-style of branch[] which essentially does stage(clone, caller); stage(caller, clone), I suggest one that has an explicit one to give to the clone. Not sure what this would look like though.

ELLIOTTCABLE commented 10 years ago

So, that solution from last night: definitely won't work. Two reasons:

  1. not very friendly to abstraction; basically have to directly call branch, can't abstract that shit away
  2. basically can't do anything that needs to consume stuff after the branch call, for similar reasons

I've realized it's irrelevant anyway. Turns out, this isn't a deficiency of branch, it's definitely specific to this use of stage. I'm pretty sure this can be solved with an extremely simple abstraction, anyway.