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

Always print redefined value names and typenames in the REPL. #805

Merged
merged 2 commits into from
Feb 6, 2020

Conversation

dhil
Copy link
Member

@dhil dhil commented Feb 5, 2020

Prior to this patch, defining two functions with the same name would
only cause the former to be printed by the REPL, e.g.

links> fun f(x) { x };
f = fun : (a::Any) -> a::Any
links> fun f(x) { x };
links>

With this patch the REPL will also print the latter entry.

The previous implementation would simply diff the previous compiler
context and the current compiler context to determine which names were
new. However, this is not sufficient to tell whether a name has been
redefined as long as the internal names are not hygienic.

This patch refines the diffing approach:

  • For values the REPL computes the set of new IR vars -- which are
    globally unique -- and uses those to determine whether a name has
    been redefined, and thus should be printed.

  • As for typenames, the REPL makes use of a slight hack. Typenames are
    represented as plain strings, so in order to check whether a
    typename has been redefined this implementation performs a reference
    equality check on the object that the typename is bound to. If that
    check returns false, then the name has been redefined.

This situation will improve once I manage to land the hygienic names patch.

Prior to this patch, defining two functions with the same name would
only cause the former to be printed by the REPL, e.g.

```
links> fun f(x) { x };
f = fun : (a::Any) -> a::Any
links> fun f(x) { x };
links>
```

With this patch the REPL will also print the latter entry.

The previous implementation would simply diff the previous compiler
context and the current compiler context to determine which names were
new. However, this is not sufficient to tell whether a name has been
redefined as long as the internal names are not hygienic.

This patch refines the diffing approach:

- For values the REPL computes the set of new IR vars -- which are
  globally unique -- and uses those to determine whether a name has
  been redefined, and thus should be printed.

- As for typenames, the REPL makes use of a slight hack. Typenames are
  represented as plain strings, so in order to check whether a
  typename has been redefined this implementation performs a reference
  equality check on the object that the typename is bound to. If that
  check returns false, then the name has been redefined.

This situation will improve once I manage to land the hygienic names patch.
@dhil dhil merged commit dfe8175 into links-lang:master Feb 6, 2020
@dhil dhil deleted the repl-always-print branch February 6, 2020 15:50
frank-emrich pushed a commit to frank-emrich/links that referenced this pull request Sep 16, 2020
…lang#805)

Prior to this patch, defining two functions with the same name would
only cause the former to be printed by the REPL, e.g.

```
links> fun f(x) { x };
f = fun : (a::Any) -> a::Any
links> fun f(x) { x };
links>
```

With this patch the REPL will also print the latter entry.

The previous implementation would simply diff the previous compiler
context and the current compiler context to determine which names were
new. However, this is not sufficient to tell whether a name has been
redefined as long as the internal names are not hygienic.

This patch refines the diffing approach:

- For values the REPL computes the set of new IR vars -- which are
  globally unique -- and uses those to determine whether a name has
  been redefined, and thus should be printed.

- As for typenames, the REPL makes use of a slight hack. Typenames are
  represented as plain strings, so in order to check whether a
  typename has been redefined this implementation performs a reference
  equality check on the object that the typename is bound to. If that
  check returns false, then the name has been redefined.

This situation will improve once I manage to land the hygienic names patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant