Coder Social home page Coder Social logo

Comments (4)

asterite avatar asterite commented on May 14, 2024

Yes, this is because blocks don't form closures yet (and they are very experimental right now and causes all kind of codegen errors). A shorter example to reproduce the above:

a = 1
f = -> { a }
f.call

But I'll keep this open until we fix it.

from crystal.

kostya avatar kostya commented on May 14, 2024

also, problem with passing block

def f(&block)
  yield 1
end

def g(&block)
  f(&block)
end

g { |x| p x }

nil

from crystal.

yui-knk avatar yui-knk commented on May 14, 2024

On 0.7.5 these codes work!

def f(x, &block : Int32 -> Int32)
  l = ->(y : Int32) { block.call(y) }
  l.call(x)
end

f(1) { |x| p x }
# 1
def f(&block)
  yield 1
end

def g(&block : Int32 -> Int32)
  f(&block)
end

g { |x| p x }
# 1
  • type of &block is need
  • Int is not valid, Int32 is valid

Can we close this issue?

from crystal.

asterite avatar asterite commented on May 14, 2024

@yui-knk I think that now that the semantics of the language are more defined, we can close this issue. @kostya what do you think?

from crystal.

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.