[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[carmstro@twistedmatrix.com: Re: Goo Nitpicks]



Gah. I forgot to Cc: the list again. Sorry guys :-)
--- Begin Message ---
On Fri, Aug 02, 2002 at 12:41:11PM -0400, Jonathan Bachrach wrote:
> Christopher Armstrong <carmstro@twistedmatrix.com> writes:
> > On Thu, 2002-08-01 at 17:27, Jonathan Bachrach wrote:
[snip]
> > happen when I'm importing modules. Anyway, I think Python's `import'
> > statement is really perfect. 'from module import name', 'from package
> > import module', 'from package.package import module', etc. Python's
> > 'from foo import *' is basically equivalent to (use foo). Of course I'm
> > not suggesting that the syntax be stolen, but the semantics.
> 
> actually, what i had in mind which is very much like dylan and eulisp
> is the ability to do selective imports:  
> 
>   (use (each goo/math $pi))
> 
> with prefixing
> 
>   (use (prefix goo/math math/))

So, I'm confused: would this make it so I could say `math:$pi' in my module
code? If so, that's cool.

> and combined
> 
>   (use (prefix (each goo/math $pi) math/))
> 
> and in general provide filters constructed using a composition of set
> operations and renaming.  this way you could control your namespace
> more precisely.  i'll put a proposal up on the goo wiki.
> 
> i should say that i don't like python's from statement because it
> snapshots the current binding values.  what if the binding values in
> the imported from module change through reloading or redefinition.
> you're out of luck?  the only way to ensure up to date values is to
> use a module object and dereference it for every binding access.  this
> seems cumbersome to me.

Well, when I used `from', I only ever import module objects, not the names
defined inside the module (or "*", for "everything"). Modules rarely ever
get redefined themselves; when a module is reloaded, it's mutated, so
`modObj.foo' will return the new value for `foo'.

Anyway, I can understand your dislike of explicit dereferencing, but 
please, I beg of you, *let* me dereference names through their module 
names explicitly. I'm fine with goo's module system being more static 
and non-first-class, but I think this is orthogonal, and I really love 
being able to read a single snippet of code and not having to guess at 
where each name comes from.

> furthermore, the only way to know what you use of a module is to look
> for all these module dereferences and even then you won't know because
> the module is a first class object and could be passed around and
> accessed dynamically.  this is the one place where goo is trying to be
> a bit static, forcing you to list your exports and imports.

Yah, disallowing passing around modules is cool.

> > One of my _big_ annoyances, that's tangentially related, is that I have
> > to currently (use) a module to add a method to a generic function
> > defined in it. Two solutions: 1) keep a global registry of all generic
> > functions everywhere and have `dm' look up and add methods to a gf in
> > the registry, or 2) be able to explicitly tell `dm' which gf to add the
> > method to. I've not thought a lot about #1, and it seems like it will
> > probably have problems. But I'm fine with either solution.
> 
> the problem is that then you have another namespace (i.e., the generic
> function registry) that you need to control.  
> 
> in java, don't you need to use an interface to implement it?  generics
> provide an api like an interface.  from what i know about python, a
> class implements an interface when it implements all required methods.
> this is definitely more dynamic as are python's class-based
> namespaces.

Ok, so what about my second suggestion? I'd like to be able to say:

(dm mymeth mod:mymeth (o|<bar>) nil) ; of course syntax is arguable

This would attach my new `mymeth' method to the gf defined in `mod'.

Obviously this is tied into my wish for explicit dereferencing of names in
other modules, because as I said I don't like importing names from other
modules into my namespace.

> > Oh, and speaking of `mod:name' -- It seems that this syntax doesn't work
> > in regular modules. wutsupwitdat? I hope that's just an oversight: I
> > won't be able to continue coding long without it (as I said, I can't
> > stand using `use' everywhere.)
> 
> the original idea was that mod:name would only be used for module
> protection violations (i.e., getting binding values from unexported
> bindings in other modules) in the listener.  i should at least allow
> one to use that syntax to access bindings that are exported.  i didn't
> want to have people write code that accesses bindings willy nilly from
> other modules.

Yes, that's fine with me. But it's not even available for the use you
mention, outside of the REPL (i.e., in a module).

goo/user 0<= (use test)
[Loading module test...
ERROR: Unbound binding: test2:foo

where ~/.goo/mods/test.goo has only `test2:foo', and ~/.goo/mods/test2.goo
has a method `foo' defined.

Anyway, I promise to not go accessing bindings from other modules
willy-nilly. :-D

> > (b) there should be continuation prompts.
> 
> what do you mean here?

Python's:

>>> def foo():
...     print "hi"

when expecting more code, goo doesn't print anything, I'd prefer if it
printed out a distinct prompt for "I am expecting you to close a paren".

--
                                Chris Armstrong
                         << radix@twistedmatrix.com >>
                http://twistedmatrix.com/users/carmstro.twistd/
--- End Message ---