Idea for P3K

  • Thread starter Méta-MCI \(MVP\)
  • Start date
M

Méta-MCI \(MVP\)

Hi!

print become a function ; OK

I thought: and why the affection (=) would not become, also, a function?
Examples:
a = 123 return 123
b,c = 543.21, "LOL" return (543.21, "LOL")



@-salutations

Michel Claveau
 
A

Arnaud Delobelle

Méta-MCI (MVP) said:
Hi!

print become a function ; OK

I thought: and why the affection (=) would not become, also, a function?
Examples:
a = 123 return 123
b,c = 543.21, "LOL" return (543.21, "LOL")

Do you mean a = 3 would become an *expression* ?

For one thing, it wouldn't fit with the Python's function call syntax:

f(4, x=2)

currently means that f is called with first positional argument equal
to 4 and named argument 'x' equal to 2.

Moreover, it seems to me utterly unpythonic (and I don't often feel
like using this word!). Binding a name to a new value is something
that needs to be clearly visible in the code flow, not hidden within
an expression

E.g.

f(3, 4 + (x=2), 5)

has the side-effect that x is now bound to 2, but it is only apparent
if one closely scrutinises the code.
 
G

Gary Herron

Méta-MCI (MVP) said:
Hi!


Look at languages like OCAML or F #

@-salutations
Well of course, we're all well aware of other languages that allow
variables to be bound in the middle of an expression. It's just that
Python was purposely created without that (mis)feature because it's so
unclear, and easy to abuse. Most of us in the community support that
point of view and would fight the introduction of such a feature into
Python.

Gary Herron
 
B

bruno.desthuilliers

Well of course, we're all well aware of other languages that allow
variables to be bound in the middle of an expression. It's just that
Python was purposely created without that (mis)feature because it's so
unclear, and easy to abuse.

This is the same argument that has been used to justify the lack of MI
and operator overloading in Java.

Not that I would support having assignment as expressions in Python
(wouldn't fit the whole design IMHO), but this is still a somewhat
arbitrary design choice, not necessarily a GoodThing(tm) by itself -
well designed expression-based languages have their strength too.
 
J

John Roth

This is the same argument that has been used to justify the lack of MI
and operator overloading in Java.

Not that I would support having assignment as expressions in Python
(wouldn't fit the whole design IMHO), but this is still a somewhat
arbitrary design choice, not necessarily a GoodThing(tm) by itself -
well designed expression-based languages have their strength too.

Clearly this leaves C and C++ out [grin]. After all, a significant
problem in those languages is confusing = and ==. I wouldn't mind
seeing a way of assigning in the middle of an expression because it
comes up fairly frequently when one needs to do a test and save the
result at the same time. However I absolutely do not want to see the
operator be =.

However, if it's not =, then it opens another can of worms, that is,
what to call it, and where it fits into the precedence structure. <--
might work.

John Roth
 
B

bruno.desthuilliers

This is the same argument that has been used to justify the lack of MI
and operator overloading in Java.
Not that I would support having assignment as expressions in Python
(wouldn't fit the whole design IMHO), but this is still a somewhat
arbitrary design choice, not necessarily a GoodThing(tm) by itself -
well designed expression-based languages have their strength too.

Clearly this leaves C and C++ out [grin].

Indeed. Neither are expression-based languages anyway.
 
D

Diez B. Roggisch

Méta-MCI (MVP) said:
Hi!


Look at languages like OCAML or F #

The point being? Yes, shockingly enough other languages have other syntax &
semantics.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top