shawn wilson <ag4ve...@gmail.com> writes: > On Jun 25, 2013 3:11 AM, "lee" <l...@yun.yagibdah.de> wrote: >> >> shawn wilson <ag4ve...@gmail.com> writes: >> >> > Lee, can you provide an example of another programming language that >> > implements this or a thesis that describes this problem in more depth? >> >> I'm not sure what you mean --- other programming languages I know don't >> have two different kinds of 'if's and the irregularities involved with >> that. That's where an expectation that an 'if' should always be an 'if' >> and that the syntax of the same keyword should always be the same comes >> from. > > How does perl have "different kinds of if' s"? I don't think I read that in > the docs?
It has the "normal" 'if' as in if(condition) { # true branch } else { # false branch } and the syntactically appended, logically prepended 'if' as in statement if(condition); It's similar with 'unless' (and perhaps others that don't come to mind atm). To me, that's two different 'if's (and two different 'unless's) because their syntax and usage in the language are different. >> > This is sort of a p5p question but the above might cut this off at the >> > knees (or better show a gap that needs to be filled). >> >> What is a p5p question? >> > > Whether a lastif operator is appropriate (I don't see it is but maybe I'm > missing something since this has spawned a bit of a conversation). There seems to be some agreement that it won't be needed. I'm not sure if it would make sense, considering that if there was a 'lastif' statement, you'd also need statements like 'printif', 'nextif', 'redoif' and a lot of others to keep it regular. You'd have to disallow things like '$a = 5 unless($b < 4);' unless you'd create 'letif' and 'letunless' statements so you can have 'letunless($b < 4) $a = 5;'. If you had that, ppl would want things like letif($b < 4) { $a = 5; print $a; } else { $a = 7; last; } ... which then would make sense, provided that programmers don't omit the assigning of something to a variable in the block. That's probably not a good idea. Rather, I'd vote for conditionals like 'if' and 'unless' to always work the same, so you could have something like statement if(condition) { # true branch } else { # false branch } That wouldn't break existing code that uses 'statement unless(condition);'. -- "Object-oriented programming languages aren't completely convinced that you should be allowed to do anything with functions." http://www.joelonsoftware.com/items/2006/08/01.html -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/