Replies: 14 comments 22 replies
-
@blerner on Oct 22: As a point of reference: when we compile the compiler's files we have to do so in a no-imports starting environment, since we can't e.g. define lists in an environment where they're already imported. I wonder whether this namespace idea would be useful in regularizing the compiler itself? |
Beta Was this translation helpful? Give feedback.
-
Thanks for moving these over, @blerner . @shriram / @schanzer / @jswrenn – we started working on this today, and the time is nigh to bikeshed what it will look like. We also had
Ben and I also reserved a position in the syntax after
Why the extra word? Well, right now these are just going to be treated as (I think It also just helps with general future-proofing if we can specify what format is expected at the endpoint (a single module? a JSON file?) independently of how we fetch the file(s) at the endpoint (it's in shared-gdrive vs. my-gdrive, etc). |
Beta Was this translation helpful? Give feedback.
-
A principle – CS111 and CS019 students can tolerate computer-y names much better than BS students & teachers. So optimize for the latter. `use module …` seems better than bringing up language – “I thought we were programming Pyret!” (Or they'll expect Spanish to work!)
Also, my cookware doesn't go away after I use it, nor does the French language when I use it to write something.
…On Tue, Dec 29, 2020 at 7:06 AM, Ben Lerner < ***@***.*** > wrote:
I think you're fixating too much on #lang and not enough on the generality
here. The current proposal is for specific names to be available, and we
do not yet have a plan for the grammar-and-semantics-changing wonkiness
that is a full #lang. Consider the instructions we can give to BS:*
students: "You are required to use the blah namespace, .... So you write use
namespace _blah_ at the top of your file." It reads like an instruction. On
the other hand, since what we're currently considering is emphatically not
a language (in the sense of #lang ), it makes no sense to have lang be the
determining keyword to start the use-statement. We need a single keyword
here, so that it's future proof to whatever other improvements we make and
so that the grammar is unambiguous (without having to constantly carve out
additional keywords in the future). We've already reserved use , since the
beginning of Pyret, so we know it doesn't conflict with anything.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (
#1555 (reply in thread)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAA5IU25O2F5JQRWXNSVF3LSXHWABANCNFSM4VGDA2PQ
).
|
Beta Was this translation helpful? Give feedback.
-
All fine, but `use` still doesn't really cut it for me. Use it to do *what*?
I wish we could find a word that implied something like "be defined by".
|
Beta Was this translation helpful? Give feedback.
-
I’m thinking “use graphing,” “use a strategy,” etc. The “to do what” is the program that follows.
Do you prefer namespace to use? Trying to understand the principle other than natural language quibbles here
…On Tue, Dec 29 2020 at 10:31 AM, Shriram Krishnamurthi < ***@***.*** > wrote:
All fine, but `use` still doesn't really cut it for me. Use it to do
*what*?
I wish we could find a word that implied something like "be defined by".
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (
#1555 (comment)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAA5IU5DDT76ZOKHVVWAOD3SXIN73ANCNFSM4VGDA2PQ
).
|
Beta Was this translation helpful? Give feedback.
-
I think it's useful to think of `use` in juxtaposition to `include` or
`import`. It's hard to unpack recall from other languages, but those seem
more clearly explanatory of what is going on: "include everything from
there", "import things from there". Whereas `use` doesn't imply "this might
define a sub/super-language" — it just looks like another kind of import
statement, but it's really quite different.
Concrete suggestion: let's borrow from Grace and call it `dialect`? That
implies some kind of modification to the language. Initially the dialect is
not a sweeping language change; over time it might be.
|
Beta Was this translation helpful? Give feedback.
-
I feel like the juxtaposition with `include` and `import` misses the point
of the two words, because `use` *plus some other word* is what you'd
juxtapose with import or include. And in the case of setting up the default
namespace, it *is* just a fancy include/import.
So think
`use namespace` vs. `import`
`use language` vs. `import`
`use environtment` vs. `import`
rather than `use` vs `import`.
We could *require* that it's written with 2 words to make sure it's clear
when it's a module-like thing vs a lang-like thing, and you'd never just
have `use shared-gdrive(...)`, only `use namespace shared-gdrive(...)` or
`use module shared-gdrive(...)` or whatever.
…On Wed, Dec 30, 2020 at 10:25 AM Shriram Krishnamurthi < ***@***.***> wrote:
I think it's useful to think of `use` in juxtaposition to `include` or
`import`. It's hard to unpack recall from other languages, but those seem
more clearly explanatory of what is going on: "include everything from
there", "import things from there". Whereas `use` doesn't imply "this might
define a sub/super-language" — it just looks like another kind of import
statement, but it's really quite different.
Concrete suggestion: let's borrow from Grace and call it `dialect`? That
implies some kind of modification to the language. Initially the dialect is
not a sweeping language change; over time it might be.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1555 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA5IU445FYH5LDDAYEW4ODSXNWBFANCNFSM4VGDA2PQ>
.
|
Beta Was this translation helpful? Give feedback.
-
I'm fine with Joe's response, that it's two words, but I'm still waiting to
hear back to my question about parsing errors. Will we be able to do a lot
better than we normally do? Can we get an error that says "after `use` you
can only write X, Y, Z", something to that effect? Then I'm fine with the
two-work version, and that does give us a lot of room to work with.
|
Beta Was this translation helpful? Give feedback.
-
Sorry, I didn't use the word "parse", but no matter.
As for the self-reporting idea, that may clash with a different comment I
made earlier in the thread, which is that a given module can be used in
several different ways: e.g., it provides only function bindings, or it
also alters the syntax. But that's not a thing we need to resolve here.
So what if someone writes `use <import-spec>` and forgets the `NAME` part?
What error would they get? It's critical that that produce a good error
message, and one that is tuned to the context, not a generic one.
|
Beta Was this translation helpful? Give feedback.
-
Would we do better if we use a single word?
`use` is highly restrictive. If a student write `use` followed by anything
illegal, it should be possible to give a very clear, use-specific error
message: "expected use to be followed …, …, or …, instead found …", and if
the last of those is a legal thing that can go after one of the "second
keywords", say so.
|
Beta Was this translation helpful? Give feedback.
-
Do we have many syntax errors with import/include?
How many times has a student typed out import/include with a non-builtin module?
The parse errors for import/include aren't great and aren't terrible,
but more importantly I haven't heard of them coming up as a major
impediment, because usually they are in provided starter code.
I think the overall answer is that the parse errors can be good if the
student typos the name of the thing between `use` and the
module-path-locator thing. If they have the wrong set of tokens, then
it degenerates to the same enumeration of cases we have with many
keyword-prefixed forms where the parser ends up in token soup.
Certainly since this has to be the first thing in the file, we can do
something custom if necessary. But I definitely don't see parsing as a
blocking issue for this the same way it might be for, say, table or
function expressions which students type all the time.
…On Thu, Dec 31, 2020 at 1:02 PM Shriram Krishnamurthi ***@***.***> wrote:
Would we do better if we use a single word?
`use` is highly restrictive. If a student write `use` followed by anything
illegal, it should be possible to give a very clear, use-specific error
message: "expected use to be followed …, …, or …, instead found …", and if
the last of those is a legal thing that can go after one of the "second
keywords", say so.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
-
Okay. I have my concerns about how this parsing will work out, but let's go
with it and see what happens. If we can make progress on blocks, that may
obviate some of it.
|
Beta Was this translation helpful? Give feedback.
-
I had a thought just now about how we might get more functionality beyond "use a different default global namespace" -- specifically, how we might get different well-formedness errors, and possibly even tweaked semantics. Supposing we define a This is risky, brittle stuff, and isn't necessarily the best interface to the compiler pipeline that we might want to support long-term. But maybe it's an interesting prototyping phase? |
Beta Was this translation helpful? Give feedback.
-
OK, so bringing this back to the
|
Beta Was this translation helpful? Give feedback.
-
(migrating from https://github.com/orgs/brownplt/teams/pyret/discussions/12)
One issue we have with CPO is that we chose a default set of names for the namespace, and this ends up conflicting with choices that library authors might want to make. If you want
set
to mean something other than builtinset
s, you have to do some contorted shadowing to make it work (and it's not clear how to do it at all if you wantList
or another datatype to mean something else).Modules don't really help, because adding more includes can't remove earlier names, just conflict with them or override them.
This is all, of course, entirely predictable if you understand
#lang
, but time is a flat circle so we have this backwards-compatibility problem.This motivates a fresh language feature to address namespace control, and also offer an incremental path forward to language levels. The proposal is to pick a new keyword to declare the environment/language level/etc, and if it's omitted you get a default environment.
For a start, the syntax will be the same as
include
, but use the different keyword, e.g.Where, to start, the
shared-gdrive
file is just a Pyret file. The semantics ofnamespace
are to skip the default includes and replace them withinclude shared-gdrive(...)
. A programmer could stillinclude
more stuff after thenamespace
declaration, following the usual rules for conflicting names, etc.If there is no namespace specified, the compiler makes a (potentially platform-specific, CPO may differ from command-line?) decision about the default namespace, effectively doing
include cpo
for some built-in modulecpo
, and so on.In the future,
namespace
can become fancier and support, perhaps, both a file of static restrictions/configurations as well as a module that declares new values, moving incrementally towards#lang
. However, this would let us get the namespace control we want today, with per-assignment or per-coursenamespace
s that leverage the current module tech to give single-line configurations for student files.Beta Was this translation helpful? Give feedback.
All reactions