Open mobluse opened 2 months ago
snek doesn't actually support python modules, the whole hack with the math functions is that they really are named math.sin
et al. .
is part of the name, it's not separate at all. Maybe those functions should also be available without the math.
prefix as well, so that you could pretend that from math import *
did what you expected?
I understand that the modules are faked, but I think it should work as if this had been in a Python3 file before the rest of the program:
import eeprom
import tone
import curses
import time
import random
import math
from eeprom import *
from tone import *
from curses import *
from time import *
from random import *
from math import *
I.e. the most common modules should be from-imported last in order to override earlier names.
stdscr is an auto created object in the Snek case.
GPIO functions, e.g. talkto() and on(), are moduleless and temperature() also. Is it reset() or eeprom.reset()? See https://sneklang.org/doc/snek.html#_reset .
62 names (from the math module) seem a bit much, IMHO it’s cleaner and closer to Python to have only math.x
names
It's standard on graphing calculators with Python to from-import math
and other modules. It makes programming easier and programs shorter.
It would be easier if
from math import *
was used because it would save people from having to typemath.
before every math function. All modules are auto imported, and I suggest all modules should also be autofrom
-imported. That means you could use all functions without a module name prefix. You could still use the fully qualified name if you want or need to. If one name shadows another you have to use the fully qualified name except for the lastfrom
-imported module.The modules could be auto
from
-imported in an order so that the most used modules are imported last.from ANYTHING import *
should be ignored likeimport ANYTHING
is ignored now.I think this would be helpful for beginners, since you don't have to type many module prefixes. This means Snek would be more competitive as a first computer language. This would also make Snek programs shorter in flash memory.
E.g.
stdscr.refresh()
would still needstdscr.
sincestdscr
is an object and not a module.