8000 overloading behaves differently with explicit vs implicit scopes · Issue #34 · timfennis/andy-cpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
overloading behaves differently with explicit vs implicit scopes #34
Open
@timfennis

Description

@timfennis
let text = " the quick brown ";

{
  fn trim(x) { 
    "..." <> x <> "..."
  }

  // Calls the shadowed trim because Any matches String inside the scope.
  print(text.trim());
}

In the example above the best match inside the current scope is used which is probably good!

let text = " the quick brown ";

fn trim(x) {
  "..." <> x <> "..."
}

// Calls the original trim because String is a better match inside the same scope?
print(text.trim());

In this example the best match in the current scope is used which is probably fine but at little confusing?

let text = " the quick brown ";

let trim = fn(x) {
  "..." <> x <> "..."
}

// Calls the overloaded trim :mild-panic-intensifies:
print(text.trim());

In this example the let binding for trim creates an implicit scope where the new trim shadows the existing trim and the call to trim only finds the last version. This is probably wrong 😢

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0