<GitHub168>
[artiq] jordens force-pushed namespace_all from 0abea0c to 2674ed1: http://git.io/vqJKi
<GitHub168>
artiq/namespace_all 2674ed1 Robert Jordens: use __all__ to structure the namespace
<whitequark>
oh, *that's* how you fight escaping symbols in modules in python
<whitequark>
wow, that's gross
<rjo>
nah. people then implement little decorators, like "@public" to manage the exported namespace but then they figure out that that is not any more beautiful.
<rjo>
the alternative is lots of _
<whitequark>
rjo: the worst part is all the imports becoming globals, I would say
<whitequark>
even with imports going into the prelude namespace (where int and friends live) it would be much cleaner.
<whitequark>
and the rest unchanged, that is.
<whitequark>
after all if you're defining something you probably want to export it, but if you're importing it you almost always do not
<rjo>
in __init__.pys you want to export imported things.
<rjo>
almost exclusively.
<rjo>
with prelude you mean __builtins__?
<whitequark>
well, the scope which is populated from __builtins__
<whitequark>
I don't suggest changing __builtins__ itself
<whitequark>
re __init__: true. but it is more of a special case.
<whitequark>
you could arrange some kind of reexport function or something, since you have importlib
<whitequark>
in fact, if import statement was just switched to the behavior i describe, the existing importlib functions would be sutable for use in __init__s
<rjo>
having to do a bit of explicit namespace managing seems ok to me. to me that is all there is. and it only ever become a problem if you want to do from X import *
<rjo>
*becomes.
<whitequark>
yes. I'm just saying that you should manage it explicitly in the uncommon case, that is __init__.py.
<whitequark>
I also like the C++ and Ruby's solution which effectively puts modules and their likeness into an another namespace entirely, lexically separated from local identifiers, but that's more drastic
<rjo>
but you can do that (import only the things you want to export in __init__). the problem there is that you put the information about something being "in a namespace" into the wrong file.
<whitequark>
no, I mean, I can't import something not in __init__ and not have it pollute namespace of *that* package without using __all__
<whitequark>
anyway, I know you can work around this, I just think it's a design that is inelegant
<whitequark>
and it's not that bad by itself, but just the fact that python is chock full of these
<whitequark>
with some half-hearted attempt to justify lack of foresigh with "simplicity" *cough*
<rjo>
"Namespaces are one honking great idea -- let's do more of those!"
travis-ci has joined #m-labs
<travis-ci>
m-labs/artiq#278 (namespace_all - 2674ed1 : Robert Jordens): The build passed.
<cr1901_modern1>
whitequark: For C++, what do you mean by "lexically separated from local identifiers". Do you mean how std::max() won't conflict with identifier max?
_florent_ has quit [Quit: Leaving]
key2 has joined #m-labs
fengling has quit [Quit: WeeChat 1.1.1]
fengling has joined #m-labs
nicksydney_ has joined #m-labs
nicksydney has quit [Ping timeout: 272 seconds]
fengling has quit [Ping timeout: 248 seconds]
<mithro>
anyone know what tool _florent_ uses to generate the ascii text in his liteXXX README files?
fengling has joined #m-labs
cr1901_modern1 is now known as cr1901_modern
<key2>
mithro: you loved it ? ;)
jaeckel has quit [Ping timeout: 250 seconds]
FabM has quit [Quit: ChatZilla 0.9.91.1 [Firefox 38.0.5/20150525141253]]
jaeckel has joined #m-labs
<cr1901_modern>
mithro: libfpgalink looks cool. May actually be worth porting my dev board to it
<mithro>
cr1901_modern: I *hate* their build system
<whitequark>
cr1901_modern: with the identifier std
ylamarre has joined #m-labs
ylamarre has quit [Client Quit]
ylamarre has joined #m-labs
ylamarre has quit [Client Quit]
ylamarre has joined #m-labs
<cr1901_modern>
whitequark: How is that different from Python, as long as you dont use "from x import *"? AFAICT, Python will bitch without the package name qualifier
<whitequark>
cr1901_modern: import artiq
<whitequark>
artiq = 1
<cr1901_modern>
Oh... well I just learned 5 minutes ago you can rename namespaces in C++...
<cr1901_modern>
but not like that o.0;
ylamarre has quit [Remote host closed the connection]
ylamarre has joined #m-labs
nic30 has joined #m-labs
nic30 has quit [Quit: Page closed]
travis-ci has joined #m-labs
<travis-ci>
mithro/migen#37 (urjtag - ff6d90e : Tim 'mithro' Ansell): The build passed.