Coder Social home page Coder Social logo

Comments (12)

porcuquine avatar porcuquine commented on August 28, 2024

This should get you started:

Comments in code at least intend to point to where this should happen:
https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L481-L485
https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L551

And here is how it's done in lang.lisp:
https://github.com/lurk-lang/lurk/blob/master/impl/lang.lisp#L805-L813
https://github.com/lurk-lang/lurk/blob/master/impl/lang.lisp#L877-L885

Note that Continuation::Tail is (for now) called CALL3-CONTINUATION in lang.lisp.

from lurk-rs.

namin avatar namin commented on August 28, 2024

I can think of at least two ways of doing it:

  • have a new kind of call continuation for zero-arg functions
  • transform (lambda () ...) to (lambda (dummy) ...). This seems in the spirit of the auto-currying that is currently done.

Any thoughts?

from lurk-rs.

porcuquine avatar porcuquine commented on August 28, 2024

I think the most economical thing (both conceptually and in terms of computation) is to use Continuation::Tail. This is exactly a continuation awaiting no more values. That's why it used to be called Call3: it's what comes after the second value (the argument, first was the function) has been supplied.

Although the context of the code there may have drifted, I think that (just use Tail) is what this comment is trying to communicate: https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L763-L765

from lurk-rs.

namin avatar namin commented on August 28, 2024

I am not sure what you have in mind for distinguishing the zero-arg case from the one-arg case when matching on Continuation::Call.
https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L535

from lurk-rs.

namin avatar namin commented on August 28, 2024

Sounds like we need to change handling of lambda too:
https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L307

from lurk-rs.

porcuquine avatar porcuquine commented on August 28, 2024

Ah, I think that if it turns out we can use Continuation::Tail for the zero-arg case, then we actually won't need to add anything there. In that case, the change will just be to delete the comment, as the implementation will be a no-op.

I think this is where we have parsed the input and know we need to handle a zero-arg function. https://github.com/lurk-lang/lurk-rs/blob/master/src/eval.rs#L473

from lurk-rs.

namin avatar namin commented on August 28, 2024

We still have two steps: we need to evaluate the fun_form, and then we need to invoke it. It's not just the invocation part.

from lurk-rs.

porcuquine avatar porcuquine commented on August 28, 2024

Right, I agree with that. Am just paging this in. If my previous makes sense as far as it goes, then I think you're on track here.

from lurk-rs.

namin avatar namin commented on August 28, 2024

Yeah, sorry if it would be faster for you to implement than to explain what you had in mind :D

I am not convinced we can do it with one Continuation::Tail because how are we going to get the body out of the fun_form?

Thanks.

from lurk-rs.

namin avatar namin commented on August 28, 2024

I think using the one-arg translation of zero-arg functions might be the most economical, since it's just a syntactic change.

from lurk-rs.

porcuquine avatar porcuquine commented on August 28, 2024

I think you might be right. I don't have time to trace this all down right now, and I suspect that if I do I will end up with the same conclusion. So… I think it's probably worthwhile for you to go ahead and implement that way. If a viable competitor emerges, we can look at it, but if you have a line on this, feel free to proceed.

from lurk-rs.

namin avatar namin commented on August 28, 2024

Sounds good, thanks!

from lurk-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.