Extending language syntax
Hi all,
I've just joined you, I hope I'll not make you loose your time with
questions already covered.
Sorry, if my suggest represents lot of work (certainly too much) and about
my lack of knowledge about internal implementation, but I hope opening a
discussion can help.
I would suggest to introduce a new statement to provide a way to extend
language syntax.
Abstract:
While reading this article about None
historyhttp://python-history.blogspot.fr/2013/11/story-of-none-true-false.htmlI
realised I was not alone to wonder about some aspect of the language.
Some of these are:
- constant and immutability
- null object and "None is a singleton"
- readability of code
*Constant:*
It's a convention, no matter with that.
My question is more if there is no memory overuse to have fixed values that
behave as variable.
*Null Object:*
NoneType is not overridable.
Having null objects instance of NoneType wouldn't make sense ?
Can't assign keywords so "None is a singleton".
Wouldn't it be more simple to have "keyword" type and be able to assign a
keyword to a variable ?
With an object hierarchy like: keyword <- ReservedKeyword
I find it can make clearer why some keywords are reserved without changing
actual behaviour.
*Readability of code:*
I have shouldDsl http://www.should-dsl.info/ use case in mind.
The introduction illustrate my thought:
"*The goal of Should-DSL is to write should expectations in Python as clear
and readable as possible, using an “almost” natural language (limited by
some Python language’s constraints).*"
I find ShouldDsl perturbing, as the aim is laudable but the implementation
stays a hack of the language.
I see the influence of functional paradigm in this syntax and agreed with
the fact it becomes a "must have".
I love Python syntax and find, it has very few limits, but maybe it can be
improved by reducing some constraints.
One concerns in extending syntax is that the language can evolve on users
usage.
I see it like an open laboratory where developpers experiments new keywords
like "should" implemented in their favorite language and when this keyword
is largely accepted by the community it can finally integrate the core.
*A solution*:
I was first thinking of a statement like "Instance" to declare an immutable
object with a single instance (like None), but I then consider how it would
be great to be able to extend the syntax.
I thought the keyword "Keyword", which exists in clojure for
examplehttp://clojure.org/data_structures#Data%20Structures-Keywords,
can do the job.
A first implementation can be:
Keyword <name>(
participants (6)
-
Andrew Barnert
-
Charles-François Natali
-
Chris Angelico
-
Gregory Salvan
-
Haoyi Li
-
Nick Coghlan