last day (38 days later) » 

2:34 AM
@isaacg would be nice if we could talk through some details of Pyth5 in a reasonably interactive format
 
 
14 hours later…
4:42 PM
Hi, sorry for not coming in here sooner.
 
no problem
so I have a couple of things to discuss
 
Sure
 
first of all - PEP8 79 column conformance
do we really want it?
I would prefer 100 or 120 columns
 
Seems fine to me. I was using PEP8 by default, hadn't really thought about it.
 
which one, 100 or 120?
 
4:45 PM
I usually view documents at 120 columns, so that'd be my preference, but either is fine.
 
ok
second point is project structure
I think it would be better if we'd turn Pyth into a proper Python package
and put it on pypi
 
Seems like a good idea to me.
 
so people can just do sudo pip3 install pyth
and get a proper pyth command
 
Yeah, better than a github clone operation.
 
there is one tiny disadvantage
there won't be a simple pyth.py in the root anymore
if you're cloning for development you have to run sudo pip3 install -e .
 
4:47 PM
That's not so bad.
 
ok
regarding pypi registration
I'm going to need your email as author email
 
isaacg@mit.edu
 
I'll register it with you as author, and me as maintainer - ok?
 
Sounds good to me.
 
I want to transfer pypi ownership to you too
do you have a pypi account?
 
4:48 PM
No
I'll make one
 
it would be nice if you'd add me as maintainer on pypi and github - but that's your decision to make
 
I will
 
I've done most of the boilerplate for Pyth 5, and can really start working on implementing the operators - I just need to fix the above package structure and tests
 
Awesome
 
I've done a couple of cute things
that should make operator overloading quite a bit easier
 
4:50 PM
My pypi acount is isaacg
That's a nice one
 
I also have cleanly seperated Pyth
there is now a lexer.py that creates tokens
parser.py turns tokens into an AST
codegen.py turns an AST into Python code
and env.py runs the code and defines the builtins
 
Beautiful
 
everything is pretty clean, except the lexer
but you can't really make clean lexers =/
they're massive state machines
 
Can it handle things like F?
 
that will be handled at the parser
in particular, I have made the lexer pretty interesting regarding comments, strings and UTF-8
the lexer operates on bytes, not on strings
 
4:53 PM
I see.
 
if it encounters a ", it will read an UTF-8 string
if it encounters a ." it will read a binary string, and turn it into octects
 
Ah. That's nifty.
Does the lexer handle numbers, too?
 
so ."test" becomes [116, 101, 115, 116] in the code
@isaacg yes
 
I see. That's be creat for golfing komogorov problems
great*
 
it also correctly detects "dot operators", like .A
 
4:55 PM
Excellent.
 
and the leading zeroes are seperate tokens
very importantly - it can handle newlines, indentation and comments unambiguously
 
What about \A?
 
that becomes "A" in the code
don't think .\ would be useful
 
Is that lexer level or parser level, I mean?
 
lexer
the lexer strips away any amount of even spaces at the start of a line
so you can indent by 2 or 4 spaces
 
4:57 PM
Same as -m, basically?
 
yes, but I've made it unambiguous
 
Seems good.
 
newlines are removed, unless the previous line ends in a number and the next starts with a number or .
 
Hm
That I'm not sure about.
 
the only use for newlines is token seperation
 
4:58 PM
One very useful property of newlines is that they can trigger printing in anything
 
care to elaborate?
 
For instance, a $ expression
 
oh about that
I think about fully removing $
 
or if you want to print the return value of a p.
 
and replacing it with a Pyth interpreter instead
 
4:59 PM
Like an exec function?
 
like a run_code function
 
Right.
 
$"+3 5" would return "8"
 
That seems good. And running Python code would just be impossible?
 
yes
it's a security hazard anyway
 
5:01 PM
True.
 
also it breaks the self-containment of Pyth
 
Yeah.
 
without $ we could start writing, say, interpreters in C++
 
That's a good point.
 
I'm purging tuples entirely, but I'm not entirely certain what to do with the number system
 
5:02 PM
Here's an example of where newlines are useful. Say you want to pop a list and print he result. Pop is default non printing, so you put a newline in front.
What about the number system?
Removing floats?
 
what I was thinking about is to merge a int/decimal/fraction system into one 'number' type
using the decimal and fraction modules
 
Seems good overall.
 
I also had a tiny idea not really relevant that could be imported into Pyth right now
 
Yeah?
 
+Z) -> abs(Z), -Z) -> -abs(Z)
 
5:05 PM
Ah.
Sure, why not?
 
there's a couple points about the unified number system
first: what should the precision be?
100 decimal digits?
30?
 
What's the downside to more digits?
 
slow
 
OK
 
this is where the optional gmpy2 dependency comes in, too
without it it could be slow
 
5:07 PM
Right - faster when it's needed
I think 100 digits is a good idea.
It's a golfing language - it's OK to be a bit slower.
 
basically my idea is that when you say for example /100 30 that internally it stays a fraction
auto-print will print the decimal though
and we'll have functions to get the denominator and numerator
 
And when you say ^2 .5it makes an extended decimal, right?
 
yes, it will compute the result as a 100 digit decimal
 
Rationals seem good as the default.
And decimals as the backup.
 
that's exactly my idea
 
5:09 PM
OK.
 
complex numbers would work the same, but as a pair of these 'numbers'
 
Sure.
 
then the big question I have left
how much of the functions should we redesign/move around?
 
As many as we need to.
 
before I start implementing stuff it could be useful if we'd just write the docs first
to see what everything should do
 
5:11 PM
OK. There's 2 parts to that, I guess - what we want to keep, and what we want to add.
 
3. what we want to remove
 
Right.
 
4. what we want to move around
there's some things that I'd prefer as a two-character operator
 
E, for instance.
 
hmm maybe
how many digits should be autoprinted btw?
 
5:13 PM
Hm.
 
the problem with 100 decimal digits is that if you do /1 3 you get 100x 0.33333333333333333
 
I'm not really sure.
One thing I was wondering about is more ways to manipulate functions. = and F are great, and we should have more things like them. One source of more single letter commands for them is statement characters. #, I, E, D, W, L, M, A.
I'm going to start adding some of those to Pyth.
But I'm sure more could be done in Pyth 5.
 
the new lexer/parser/codegen model should be very flexible
about the arity in the docs
it never was clear what N and co means
 
Ah.
N basically means it won't be autoprinted at the beginning of a line.
Wasn't very useful or important.
 
err
I mean
S and X
 
5:23 PM
S is special - doesn't take arity.
X is unbounded.
 
oh I just spotted a mistake
S autoprints, but shows as N
wait
a lot of them don't make sense
 
Sorry.
N means it is autoprinted
stuff like V, W, R, etc. have Y.
 
i think for now I'll omit it from the docs
 
Seems good.
 
keeping the docs to 80 columns or something small seems nice
for split view editors pyth/docs
 
5:28 PM
Sure, why not.
Speakin gof the docs, web-docs shouldn't be a separate file, it should be autogenerated.
 
yeah
I was thinking of that too
for now I'm not going to do the server at all by the way
in fact, now that Pyth will be a proper package, I think it should be fully standalone
you should be able to just require Pyth in your webserver and it should work
 
Make it a separate repository, perhaps?
 
yeah, like that
you should be able to just do import pyth; pyth.run_code("Q", "13")
 
5:54 PM
@isaacg what's your opinion on dependencies?
most notably nose for testing
 
6:09 PM
Dependencies are OK by me, if they make the code nicer.
 
7:09 PM
@isaacg check out the testing framework I made: github.com/orlp/pyth5/blob/master/test.py
 
That's certaintly a novel approach.
Or is that just how unittest works generally?
Either way, looks nice.
 
nah, this is not how unittest usually works :P
@isaacg about the license - you use MIT, but I prefer the zlib license
do you want to continue using MIT, or switch to zlib?
zlib allows anything, except claiming a modified version is the original
 
I'll read them over.
 
I don't like about MIT that programs have to produce / give the license if they use parts of the code
 
7:48 PM
Switching to zlib seems fine to me. If someone wants to use Pyth for something, I don't really care how.
@orlp
 
 
Looks good.
 
8:21 PM
@isaacg looks like pyth is already taken on pypi
pyth-lang?
 
Oh, right, I remember seeing that.
pyth-lang is fine.
 
@isaacg hmm, should I also make the package name (the thing you import) pyth_lang to prevent collision?
I don't want to change the command though, I want pyth as the command
 
I guess so.
Yeah, pyth as the command seems good.
 
8:39 PM
@isaacg could you do this?
git clone https://github.com/orlp/pyth
python3 -m unittest
 
Sure.
----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
 
sorry
did you cd into pyth first?
 
Yes
 
python3 -m unittest discover
 
Same output
 
8:41 PM
python3 -m unittest pyth.test
wait
fuckkkkkkkk
 
AttributeError: 'module' object has no attribute 'test'
 
git clone https://github.com/orlp/pyth5
 
oh
 
hurr durr
 
Right, of course.
 
8:42 PM
I made you clone my fork ^^
so just clone the pyth5 followed by python3 -m unittest
 
...............
----------------------------------------------------------------------
Ran 15 tests in 0.003s

OK
 
cool
here's the real magic
 
I agree
 
python3 -m unittest pyth_lang.test.Add
 
ImportError: No module named 'pyth'
 
8:44 PM
ofc
pyth_lang hurr durr
 
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
 
keep forgetting these name changes
 
:Looks good.
 
ok, everything works then
 
Sweet.
 
8:44 PM
pip3 install -e .
and then pyth
 
I've got pyth hooked up to current pyth, so I'd rather not.
 
all right
you could edit setup.py
entry_points={"console_scripts": ["pyth=pyth_lang.pyth:cli"]},
 
OK, I'll make it pyth5
 
to
entry_points={"console_scripts": ["pyth5=pyth_lang.pyth:cli"]},
(sorry, I keep running into stackexchange chat throttling)
 
It didn't work
Oh, I forgot to sudo it
It works!
 
8:48 PM
pip3 uninstall pyth-lang
and then pyth5 should be gone again :)
 
That didn't work
 
sudo?
 
Can't uninstall 'pyth-lang'. No files were found to uninstall.
Even with sudo
 
that's odd
what if you try to uninstall pyth_lang?
 
Same message, down to the -.
 
8:51 PM
pip3 uninstall .
otherwise I don't know
 
No output, no effect on pyth5
Weird.
 
@isaacg I reproduced on my linux server, will try to debug
 
Good luck.
 
 
1 hour later…
9:57 PM
@isaacg well that was a weird trip
went to freenode.org#python
turns out you're not supposed to run pip as sudo
 
10:14 PM
Oh
 
@isaacg it's going to have to be a manual deinstall - I've found a clean way to install/uninstall in the future
what OS do you run?
@isaacg you'll have to do something like this
sudo rm /usr/local/bin/pyth5
sudo rm /usr/local/lib/python3.2/dist-packages/pyth-lang.egg-link
sudo vim /usr/local/lib/python3.2/dist-packages/easy-install.pth
and remove the line with pyth-lang on it
in the future, use pip3 install --user -e . and add ~/.local/bin to your path
sorry, I wasn't aware of this
 
11:11 PM
@isaacg I'm changing the order in which the operators come
to !"#$%&'()*+,-/:;<=>?@[]^_`{|}~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW‌​XYZ
(this is lexicographical order, except the symbols come first, and the lowercase letters come before uppercase)
 
11:46 PM
I run ubuntu
No problem, I'm going to leave it installed anyways
We should just know how this works.
The operator order for the data.py stuff? or for the docs?
 
@isaacg pretty much everywhere
I do suggest you uninstall and reinstall properly
 
OK, seems fine. Having a standard order seems like a good idea.
 
I will forget how sometime in the future
 
OK
 
and then it'll be painful
 
11:54 PM
For the reinstall, I just use pip without sudo?
 
yes
those are proper installation instructions
 
For the third uninstall step, with easy-install.pth, none of the lines mention pyth-lang
import sys; sys.__plen = len(sys.path)
/home/isaac/prog/pyth5
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
 
the pyth5 one
should be removed
 
OK]
 

  last day (38 days later) »