[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Andrew Barnert via Python-ideas
On Dec 21, 2019, at 15:59, Chris Angelico wrote: > > It's not just about performance. It's also about expressing a concept. > A tail call IS a call, and the correct way to write this is to do > stuff, and then do whatever a call does. Looking at languages that try to express similar semantics wi

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
On 2019-12-21 5:22 p.m., Chris Angelico wrote: On Sun, Dec 22, 2019 at 7:06 AM Soni L. wrote: > On 2019-12-21 4:52 p.m., Chris Angelico wrote: > > I'm not sure I understand what switch construct would translate into > > this style. Can you show an example of code in some other language, > > h

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
On 2019-12-21 5:52 p.m., Kyle Stanley wrote: > Python is not an OOP language. If you want to breathe and preach OOP, you should quite frankly just use Java. Python isn't *strictly* or *exclusively* an object-oriented programming language, but since it does have strong support for OOP featur

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Chris Angelico
On Sun, Dec 22, 2019 at 10:46 AM Greg Ewing wrote: > > On 22/12/19 9:04 am, Soni L. wrote: > > > switch (op) { > >[...] > >case OP_TAILCALL: { > > adjust_regs(); > > some_other_stuff(); > > /* fallthrough */ > >} > >case OP_CALL: { > > make_the_call_happen(); >

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Greg Ewing
On 22/12/19 9:04 am, Soni L. wrote: switch (op) {   [...]   case OP_TAILCALL: {     adjust_regs();     some_other_stuff();     /* fallthrough */   }   case OP_CALL: {     make_the_call_happen();     break;   } } Relying on fall-through in a switch is a micro-optimisation that may hel

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Kyle Stanley
> Python is not an OOP language. If you want to breathe and preach OOP, you should quite frankly just use Java. Python isn't *strictly* or *exclusively* an object-oriented programming language, but since it does have strong support for OOP features, saying that "Python is not an OOP language" simp

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread MRAB
On 2019-12-21 20:09, Soni L. wrote: On 2019-12-21 4:58 p.m., Gregory Salvan wrote: Years ago there was an interesting movement called anti-if campaign, now it's more promotional, but the concept of "anti if" may help you find ways to remove the cases where your suggest "and if" and "or if" c

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Chris Angelico
On Sun, Dec 22, 2019 at 7:06 AM Soni L. wrote: > On 2019-12-21 4:52 p.m., Chris Angelico wrote: > > I'm not sure I understand what switch construct would translate into > > this style. Can you show an example of code in some other language, > > how you'd translate that same logic into today's Pyth

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
On 2019-12-21 4:58 p.m., Gregory Salvan wrote: Years ago there was an interesting movement called anti-if campaign, now it's more promotional, but the concept of "anti if" may help you find ways to remove the cases where your suggest "and if" and "or if" can apply. This article is particular

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
On 2019-12-21 4:52 p.m., Chris Angelico wrote: On Sun, Dec 22, 2019 at 6:35 AM Soni L. wrote: > > > > On 2019-12-21 4:15 p.m., Andrew Barnert wrote: > > > On Dec 21, 2019, at 08:41, Soni L. wrote: > > > > > > I'd like to see the ability to do: > > > > > > if x: > > > 1 > > > and if y: > > >

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Gregory Salvan
Years ago there was an interesting movement called anti-if campaign, now it's more promotional, but the concept of "anti if" may help you find ways to remove the cases where your suggest "and if" and "or if" can apply. This article is particularly well written: https://code.joejag.com/2016/anti-if-

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Chris Angelico
On Sun, Dec 22, 2019 at 6:35 AM Soni L. wrote: > > > > On 2019-12-21 4:15 p.m., Andrew Barnert wrote: > > > On Dec 21, 2019, at 08:41, Soni L. wrote: > > > > > > I'd like to see the ability to do: > > > > > > if x: > > > 1 > > > and if y: > > > 2 > > > or if z: > > > 3 > > > > > > The truth ta

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
On 2019-12-21 4:15 p.m., Andrew Barnert wrote: > On Dec 21, 2019, at 08:41, Soni L. wrote: > > I'd like to see the ability to do: > > if x: > 1 > and if y: > 2 > or if z: > 3 > > The truth table for these would be: > > x | y | z | result > 0 | _ | 0 | (none) > 0 | _ | 1 | 3 > 1 | 0 |

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Andrew Barnert via Python-ideas
> On Dec 21, 2019, at 08:41, Soni L. wrote: > > I'd like to see the ability to do: > > if x: > 1 > and if y: > 2 > or if z: > 3 > > The truth table for these would be: > > x | y | z | result > 0 | _ | 0 | (none) > 0 | _ | 1 | 3 > 1 | 0 | _ | 1,3 > 1 | 1 | _ | 1,2,3 > > and each statement i

[Python-ideas] Re: "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Anders Hovmöller
Could you give an example of some real code that would be improved by this construct? > On 21 Dec 2019, at 17:42, Soni L. wrote: > > I'd like to see the ability to do: > > if x: > 1 > and if y: > 2 > or if z: > 3 > > The truth table for these would be: > > x | y | z | result > 0 | _ |

[Python-ideas] "and if" and "or if" for trailing if statements - including explicit fallthrough

2019-12-21 Thread Soni L.
I'd like to see the ability to do: if x:   1 and if y:   2 or if z:   3 The truth table for these would be: x | y | z | result 0 | _ | 0 | (none) 0 | _ | 1 | 3 1 | 0 | _ | 1,3 1 | 1 | _ | 1,2,3 and each statement is evaluated once, when encountered. (as such, y and z may not be evaluated at a