Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global Func objects #876

AlasdairWJ opened this issue Apr 26, 2015 · 1 comment


Copy link

commented Apr 26, 2015

It seems rock doesn't recognize globally declared function objects.

myFunc: Func(Int)
myFunc_imp: func (i: Int) {
    "%d" printfln(i)
main: func {
    myFunc = myFunc_imp

The compiler throws a 'No such function' error on myFunc(10). This also fails:

other := func {
    "Hi!" println()
main: func {

but can however, be worked around like this:

f := myFunc
g := other
zhaihj added a commit to zhaihj/rock that referenced this issue Apr 27, 2015

This comment has been minimized.

Copy link

commented Jul 8, 2015

My version of the test, using string interpolation & more importantly, making sure closures still work in that context:

x := 2

myFunc: Func (Int)

myFunc_imp := func (i: Int) {
    "i = #{i}" println()
    x = 4

main: func {
    myFunc = myFunc_imp
    "before, x = #{x}" println()
    "after, x = #{x}" println()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.