new language ideas

Hi all, I've been tinkering with a bit of a pet project on and off for some time now. I'm basically trying to adapt the python style/syntax for a language that is a bit better suited as a classical systems programming language. To be able to program with Python at the high level and something very pythonesque at the lower level is very appealing. :) Well, when thinking about this, I've come up with a few ideas I think might benefit Python as well. Please forgive me if these are repeats, I've never seen anything related to this in the PEPs or on the list. I'm just tossing these out for Python's benefit... /me dons asbestos long-johns... Multiline comments -------------------------- #BEGIN ... #END Everything in between is ignored. It would be very useful when debugging decent sized blocks of code. I know certain editors can auto-comment blocks, but it can be difficult to un-auto-comment said block. The same smart editors could colorize the block accordingly, minimizing readiblity issues. __doc__ variable ------------------------ docstrings are really a special case of programmer documentation. It'd be a lot nicer if there were some way to isolate certain portions of information in the docstring. Most contain a short description as well as the expect things (I won't say types on this list) ;). docstrings could be aliased through the dictionary __doc__. The exact symantics are a bit fuzzy right now, but I wanted to toss out the idea for public scrutiny. Here's an example: def f(x): "does nothing, really." return(x) In this case, __doc__.desc would equal the docstring. This would allow for backward compatibility and allow for extension. Think author, webpage, and version at the global scope and pre/post conditions, dynamically created information about a function/class. bit access of integers ---------------------------- Like strings, we can use [] to index into python integers. It'd be a nice way to set/read individual bits of a given integer. For example: x = 5 x[0] = 0 print x (prints 4) The details of how to index (I was assuming big-endian in this example) are open to discussion. This would make bit-banging in python be even easier than C (not to mention easier to read). This assumes we want Python to be good at bit-banging. ;) alternative base notation --------------------------------- Python inherited C's notation for numbers of non-decimal bases. I propose another with simpler syntax: number_base. An example: x = 24b_16 y = 1001_2 z = 96zz_36 The range for this notation would be 2 to 36 for the base. This allows for the entire alphabet plus numbers to be used as numerical placeholders. I'd be happy if _2, _8, _16 were the only ones implemented because those are the most commonly used. It would be nice to treat it almost as if it were a call to a radix() function. I think the notation has a nice look to it and I think makes it easy to read. So that's it for now. Let me know what you think. -Brian Rzycki

At 08:27 PM 11/2/03 -0600, Brian Rzycki wrote:
Just triple quote. I usually use """ for actual strings in my programs, and if I need to comment out a block I use '''.
Integers are immutable. What you want is a bit array; you could write one of your own in Python easily enough, or C if you need higher performance. Or maybe you could supply a patch for the Python 'array' module to support a bit type.
Python already implements 8 and 16, using 0 and 0x prefixes. Presumably, you're therefore requesting an 0b or some such. Note that you can already do this like so:
print int("100100",2) 36
However, if I were using bit strings a lot, I'd probably convert them to integers or longs in hex form, just to keep the program more compact.

At 08:27 PM 11/2/03 -0600, Brian Rzycki wrote:
Just triple quote. I usually use """ for actual strings in my programs, and if I need to comment out a block I use '''.
Integers are immutable. What you want is a bit array; you could write one of your own in Python easily enough, or C if you need higher performance. Or maybe you could supply a patch for the Python 'array' module to support a bit type.
Python already implements 8 and 16, using 0 and 0x prefixes. Presumably, you're therefore requesting an 0b or some such. Note that you can already do this like so:
print int("100100",2) 36
However, if I were using bit strings a lot, I'd probably convert them to integers or longs in hex form, just to keep the program more compact.
participants (2)
-
Brian Rzycki
-
Phillip J. Eby