Obscenely long variable names

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
fe2o3
Posts: 10
Joined: Fri Oct 23, 2015 4:47 pm

Obscenely long variable names

Post by fe2o3 » Sat Feb 27, 2016 6:14 am

No, I don't use variables names like this but I was testing a thought.

Code: Select all

MicroPython v1.6 on 2016-02-01; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> AReallyLongVariableNameThatIsNotAllThatUseful = 42
>>> dir()
['c', 'AReallyLongVariableNameThatIsNotAllThatUseful', '__name__', 'machine', 'pyb', 'Candle']
>>> x="FooBarBazQuux"*20
>>> x
'FooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuuxFooBarBazQuux'
>>> exec("%s = 69" % x)
>>> dir()
['machine', 'pyb', 'c', 'Candle', 'x', '__name__', 'FooB', 'AReallyLongVariableNameThatIsNotAllThatUseful']
>>> FooB
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'FooB' is not defined
>>> FooBa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'FooBa' is not defined
>>>
While the little PyBoard held up, I'm more worried about the integrity of RAM at this point. Tab expansion wasn't working on the longest variable name. Just thought I'd throw this out to you developers.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: Obscenely long variable names

Post by Damien » Tue Mar 01, 2016 8:03 am

If you ran this on the unix port of MicroPython then it should fail an assertion. Such cases should be handled with a proper error message so I think it is worth creating an issue on github for this. It's low priority though :)

Post Reply