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

Add syntactic holes which raise errors with full context information #197

Open
jwiegley opened this issue Apr 24, 2018 · 9 comments
Open

Comments

@jwiegley
Copy link
Member

Add a token for the symbol '_' such that when the evaluator encounters it, we print everything we know about that point in the code.

This feature could also become the basis for supporting name completion in editors.

@shlevy
Copy link
Member

shlevy commented Apr 24, 2018

Just FYI, there is some nix code here and there that uses _ as "unused argument"... Not sure if any of it is in nixpkgs these days but we definitely have some in our infra.

@jwiegley
Copy link
Member Author

Ah, OK. Maybe __ or ___?

@Profpatsch
Copy link
Contributor

Profpatsch commented Apr 25, 2018

Purescript uses ?name.

Naming “internal” variables like __var or _var is quite common in nixpkgs.

@jwiegley
Copy link
Member Author

For code completion, these holes would be treated as "stop tokens". Immediately upon encountering one, a special exception is throw with the current lexical scope as its argument, allowing a completion list to be built.

Note that completion within dynamic arguments to with blocks would still be very tricky, since the visible names would depend on the context of evaluation. Maybe the symbolic evaluator can be used here to provide the intersection of names that would always be available.

@domenkozar
Copy link
Collaborator

domenkozar commented Apr 26, 2018

nix-repl> ?name: "foobar"
error: syntax error, unexpected '?', at (string):1:1

Purescript notation sounds promising, since "Nix C++ compatibility" would refuse such syntax.

@sjakobi
Copy link
Member

sjakobi commented Jun 28, 2020

What's the status of this issue? I see that some work has been done in #398 and merged in 28ab983.

Is there more to do? What exactly?

@jwiegley
Copy link
Member Author

I'm not sure any work has started on this yet.

@sjakobi
Copy link
Member

sjakobi commented Jul 1, 2020

@jwiegley But the work in #398 is related to this issue, right?!

I ended up finding this issue because I was confused about the purpose of the NSynHole constructor:

hnix/src/Nix/Expr/Types.hs

Lines 123 to 124 in 704323e

| NSynHole !VarName
-- ^ Syntactic hole, e.g. @^foo@ , @^hole_name@

(CC @Madelinja)

@jwiegley
Copy link
Member Author

Interesting, I wasn't even aware of NSynHole, so that must have happened recently. :)

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

No branches or pull requests

6 participants