Giter Club home page Giter Club logo

Comments (5)

rtoal avatar rtoal commented on June 29, 2024

Since koan has the idea of real first-class anonymous functions, you don't have to introduce Ruby-style blocks. Simply make your loop expression like this:

'8:'  RANGEEXPR  FUNCTIONEXPR

The advantage of this is that you can use an existing function, say f, and then write something like:

8: 0..100 f

which says run f for each value in 0..100. You would check at compile time that f indeed had ONE parameter of numeric (or integer) type.

You can also use anonymous functions here:

8: 0..100 (x -> p x)

to print 0 through 100.

TL;DR Ditch the Rubyism. Ya don't need it. Ya gots functions.

from koan-lang.

jazzyfresh avatar jazzyfresh commented on June 29, 2024

sounds good to me

from koan-lang.

rtoal avatar rtoal commented on June 29, 2024

Just remember that in the previous comment FUNCTIONEXPR may or may not be a real syntactic category in your final design. If you allow variables for functions (as in the example I gave) then you aren't able to distinguish functions from non-functions there. That will be a runtime check. To avoid the runtime check, you'd have to require that the expression in that position be an anonymous function (or something like that -- something that you can tell at compile time would be a function). I'm not saying the runitme check is necessarily bad; I'm just pointing out a tradeoff.

from koan-lang.

jazzyfresh avatar jazzyfresh commented on June 29, 2024

To resolve this issue, as advised by Dr. Toal, we're going to remove the blocks and replace them with anonymous functions that have an alternative syntax.

Generally, anonymous functions take parameters that are denoted by underscores, but we are going to allow an alternative syntax that (as I understand from the conversation I had with Dr. Toal) works with for-loops and while loops.


8: 1..100 i { p: x }              c: New syntax, in which the ruby-style block is no
                                  c: longer a ruby-style block, but an anonymous function.
                                  c: Thus, blocks no longer exist in our language.
8: { p: "loop forever" }          c: While-loops will work the same way, with anonymous
                                  c: functions instead of blocks, but this anonymous function
                                  c: won't take any arguments. And since while-loops take
                                  c: break statements to jump out of the loop, I don't think this
                                  c: will cause any problems.

The reason for doing this is that there is no reason to have both blocks and anonymous functions at the same time. Blocks are ruby's way of getting around the fact that it doesn't have anonymous functions, and since our language support anon-funcs, there's no reason why we can't use them where we were going to use blocks. We shouldn't have both because the two options would be competing syntaxes, and as Dr. Toal said, there's no reason to have that either.

from koan-lang.

jazzyfresh avatar jazzyfresh commented on June 29, 2024

Also, we're ditching absolute value signs.

from koan-lang.

Related Issues (17)

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.