Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Extensions should be executed within the extended context #66

Open
robotlolita opened this issue Dec 23, 2015 · 0 comments
Open

Extensions should be executed within the extended context #66

robotlolita opened this issue Dec 23, 2015 · 0 comments

Comments

@robotlolita
Copy link
Owner

let Integer-Fib = Integer extended-by: {
  def self fibonacci
    (self === 0) || (self === 1) then: { self }
                                 else: { (self - 1) fibonacci + (self - 2) fibonacci }.
}.

use Integer-Fib in {
  Console write-line!: "Fib 20: " + 20 fibonacci.
}.
# => <Message Send Failure>: <Integer: 19> does not understand fibonacci.

Occurs because (self - n) fibonacci is executed in the global context, not the extended one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant