Skip to content

Instantly share code, notes, and snippets.

@purpleP
Last active Dec 21, 2016
Embed
What would you like to do?
What if python have parens in function calls optional where possible?
def some(a, b, c):
print a, b, c
def foo(a, b):
return a, b
def bar():
print 'bar'
#simple case, no ambiguity
a = some 'a' 'b' 'c'
# Function call inside function call. We have ambiguity.
# No ambiguity if function application have highest priority.
# This will behave like a = some(foo, a, b, c)
a = some foo a b c
# want this to to behave like some(foo(a, b), c)
# just add parenthesis
a = some foo(a, b) c
# or
a = some (foo a b) c
# what if function has no arguments?
# The solution is very easy, just behave like normal python
# treat this like a refernce to a function
bar
# if you want a call function with no arguments just do this
bar()
# args and kwargs
a = ('a', 'b', 'c')
# no ambiguity, no reason for this not to work
some *a
# nor this although I'm not sure I like that
some a='a' c='c' b=b
# and while we're on it, why not make all functions curried?
# if not all arguments have been passed to a function yet with
# parentheis less syntax make it curried
s = some 'a' 'b'
s 'c'
# prints 'a b c'
# in case of ambiguity just act like normal python
s = some 'a' 'b' 'c'
# result in printing 'a b c', s = None
# no need for clumsy
s = partial(some, 'a')
s = partial(some, 'b')
s('c')
# o
map (some 'a' 'b') ('1', '2', '3')
#prints (a b 1) (a b 2) (a b 3)
# this ambiguous, because right now python allows whitespaces in akward places
# map (partial(some, 'a', 'b'), ('1', '2', '3'))
# but that's not conforms with python format
# and I don't see any benefits from that
# also there is no ambiguity if this kind of usage of parenthesis
# would be allowed only with function call without parenthesis
@purpleP
Copy link
Author

purpleP commented Dec 21, 2016

If you haven't used Haskell you probably wouldn't like the idea. But I don't care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment