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

[parser,ast] Allow function captures as block parameters for instantiation #91

Merged
merged 1 commit into from
Dec 23, 2017

Conversation

faultyserver
Copy link
Member

Instantiation should support all of the syntax features of a normal call. This includes using a function capture as the block parameter when it is the last argument of the instantiation.

While working on improving the Spec library, I ran into a semantic error when trying to pass through a block parameter to an instantiation. The capture was treated as a regular argument, meaning the instantiation did not match any initializers, which were expecting block arguments.

An example of this usage:

deftype Thing
  def initialize(&block)
    # Storing a block for later use...already supported
    @block = &block
  end

  defstatic create(&block)
    # Passthrough with a capture as a block...would cause "No matching clause"
    %Thing{&block}
  end
end

Thing.create{ IO.puts(:hi) }

…ation.

Instantiation should support all of the syntax features of a normal call. This includes using a function capture as the block parameter when it is the last argument of the instantiation.
@faultyserver faultyserver added this to the Next milestone Dec 23, 2017
@faultyserver faultyserver merged commit faeddd0 into master Dec 23, 2017
@faultyserver faultyserver deleted the feature/capture_as_inst_block branch December 23, 2017 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant