in reply to Re: Re: Re: Self-improvement and TMTOWTDI
in thread Self-improvement and TMTOWTDI

Notationally distinct is not terribly important.

You dont think so? I disagree. The notational difference reads different and thus has a different psychological impact on a maintainence programmer. But each to their own. TMTOWTDI.

For example, 3 and 4 differ only in terms of the variable used and whether the condition is placed before or after the block; they not only do exactly the same thing, they do it in exactly the same way.

Do tell. :-) Im afraid there is a problem however, as only one of them involves a block they dont do the same thing. And this is of course beside the above point.

For example, using a while loop with a counter at the end of it that is not used for anything else other than to count out the iterations of the loop is something you can do in any language that has while loops, because the for loop is conceptually a special case of the while loop.

Well I think your claim "all languages" is a little broad. And just becuase you can do this kind of equivelency in most languages doesnt mean the point is any less relevent.

Congratulations, you discovered a general principle that applies to all languages.

You think I am unaware that the vast majority of languages support this equivelency? Hell while we are at it why dont we lose all the non GOTO examples as conceptually GOTO maps closest to "JMP" and all of the above are ultimately implement via a CMP and conditional JMP.

I'd say that these extras (like map) are not "extra" per se but are part of what makes a rich language such as Perl rich.

Er. I dont see how they can not be "extras" while at the same time being part of what makes the language rich. My earlier argument was that it was exactly these extras that do make the language so rich.

but the higher-level features, where appropriate, are less work to use.

I think the choice of one of the solutions over the next is related to both how easy it is to write and to how closely it maps onto the semantic context of the problem at hand. But I already said that didn't I.

--- demerphq
my friends call me, usually because I'm late....

  • Comment on Re: Re: Re: Re: Self-improvement and TMTOWTDI

Replies are listed 'Best First'.
Re: Self-improvement and TMTOWTDI
by jonadab (Parson) on Jan 27, 2003 at 19:44 UTC
    > The notational difference reads different and thus has a different psychological impact

    Yes, it might do that, certainly, but for that matter so does the way you format your code in terms of whitespace and whatnot. The original poster claimed that the variety was "disturbing", but I'm not sure what's disturbing about it.

    > I'm afraid there is a problem however, as only one of them involves a block

    This is Perl; a statement is a block, yes?

    > Well I think your claim "all languages " is a little broad.

    That's why I qualified, "that has while loops". Can you name a language that has while loops but does not allow for this construct? (It is now inevitable that someone will step forward and name such a language, but it will probably be one neither of us has ever used.)

    > My earlier argument was that it was exactly these extras that do make the language so rich

    Oh, I somehow missed that, amongst the other posts. The other poster's point that the variety is disturbing is the one I disagree with really. Sorry for any confusion.

     --jonadab

      but I'm not sure what's disturbing about it.

      Some people dont like to make decisions. Choice mandates making decisions. So ditherers probably dither more with perl than with more restrictive languages just because of this. Its probably compounded by the fact that often there is little difference between the options, IME the less difference the harder the choice. As I said however I rejoice in the options. Id rather dither occasionally than have to fight the language to do something I want to do.

      This is Perl; a statement is a block, yes?

      Nope. :-) Read perlsyn: Simple statements and perlsyn: Compound statements. The following is a selection of what seemed to me to be relevent paragraphs.

      Perl, a sequence of statements that defines a scope is called a block. Sometimes a block is delimited by the file containing it (in the case of a required file, or the program as a whole), and sometimes a block is delimited by the extent of a string (in the case of an eval).

      But generally, a block is delimited by curly brackets, also known as braces. We will call this syntactic construct a BLOCK.

      Modifiers are considered to be simple statements, as follows

      STMT if EXPR STMT unless EXPR STMT while EXPR STMT until EXPR STMT foreach EXPR

      Whereas compound statements are scoped as follows

      if (EXPR) BLOCK if (EXPR) BLOCK else BLOCK if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK LABEL while (EXPR) BLOCK LABEL while (EXPR) BLOCK continue BLOCK LABEL for (EXPR; EXPR; EXPR) BLOCK LABEL foreach VAR (LIST) BLOCK LABEL foreach VAR (LIST) BLOCK continue BLOCK LABEL BLOCK continue BLOCK
      The clearest example I can think of is as follows
      D:\Development>perl -Mstrict -wle "my $foo=1 if 0; print defined($foo) + ? $foo : 'undef'" undef D:\Development>perl -Mstrict -wle "if ( 0 ) { my $foo=1 } print defin +ed($foo) ? $foo : 'undef'" Global symbol "$foo" requires explicit package name at -e line 1. Global symbol "$foo" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.
      So the first example uses a simple statement with a modifier. The my declaration is at the highest scoped level (the eval block that the -e represents). Whereas in the second example the my declaration is scoped to the affirmative block in the if.

      neither of us has ever used.)

      Heh, or even heard of. :-) And i didnt see your qualifier. Sorry.

      The other poster's point that the variety is disturbing is the one I disagree with really. Sorry for any confusion.

      Me too. No prob. :-)

      --- demerphq
      my friends call me, usually because I'm late....