Re: Nasty language semantics (Was: error message I don understand) [message #174920 is a reply to message #174919] |
Mon, 18 July 2011 01:18 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 7/17/2011 7:51 PM, August Karlstrom wrote:
> On 2011-07-18 01:23, Jerry Stuckle wrote:
>> I guess a certain level of maturity is needed to recognize an academic
>> language from one which is truly usable in the real world.
>>
>> My guess is you've never worked on a real multi-programmer project in a
>> business environment. Or maybe not even a single-programmer project in a
>> corporate environment.
>
> I have worked in all kinds of constellations and seldom have I
> experienced a problem with the language at hand being too restrictive,
> quite on the contrary, obscure language features in combination with
> programmer "cleverness" (in the usual "power corrupts" sense) have given
> rise to several maintenance headaches.
>
> August
>
What a way to sidestep the question. You just confirmed my hypothesis.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: Nasty language semantics (Was: error message I don understand) [message #174921 is a reply to message #174917] |
Mon, 18 July 2011 08:22 |
Tim Streater
Messages: 328 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
In article <ivvorv$19k$1(at)dont-email(dot)me>,
August Karlstrom <fusionfile(at)gmail(dot)com> wrote:
> On 2011-07-18 00:06, Tim Streater wrote:
>> Also at the time academics were pushing the
>> single-entry-single-exit bullshit, so there was no return statement.
>
> I guess a certain level of maturity is required to appreciate some of
> these "restrictions". The return statement goes against the idea of a
> truly structured goto-less programming language. Wirth introduced the
> return statement (tried it) in Modula-2 and in the first versions of
> Oberon but replaced it with a return clause (single exit point) in
> Oberon-07. Here is a quote by Niklaus Wirth from "Differences between
> Oberon-07 and Oberon"*:
>
> "The result of a function procedure was specified by a return statement.
> This form has the unpleasant property that the return statement is
> syntactically disconnected from the function procedure declaration,
> similar to the exit from the loop statements. It is therefore difficult
> to check, whether or not a function procedure declaration specifies a
> result, or perhaps even several of them. Now the result specification
> becomes syntactically a part of the procedure declaration, and vanishes
> as an independent statement form."
Mmm, and code becomes unreadable as a result, with lots of extra if-else
nesting to try to ensure that from a given point where I would do a
return, no more code is going to be executed in the function. Unreadable
because I have to spend a long time convincing myself that no more code
will, in fact, be executed.
I haven't used a goto since 1978 when I gave up writing FORTRAN. Oh
wait, tell a lie, there was a period when I had to, since I was obliged
to write in Pascal and there was no return statement. So I faked one by
labelling the end of the function with 999: and then doing goto 999.
Thank God that piece of impractical nonsense has gone the way of the
Dodo. Early return simplifies code; I regard it as my responsibility to
ensure I return the right thing.
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|
Re: error message I don understand [message #174926 is a reply to message #174903] |
Mon, 18 July 2011 15:19 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
Denis McMahon wrote:
> Thomas 'PointedEars' Lahn wrote:
>> In the end an oversimplified, wrong explanation. It is a syntactical
>> requirement, not a functional one:
>>
>> $a = x();
>
> Here you're assigning the return value of the function x() to the
> variable $a.
>
>> $a[0] = 42;
>
> Here you're writing to the variable $a (or rather, in this case, to an
> element of the array that is variable $a).
>
> Neither of these is trying to assign (write) a value to the return value
> of the function call.
Yes, it is. The return value of the function is a one-element array, and
with that assignment I am writing to the same memory area (or another memory
area that holds a copy of the former's content) by changing the first
element of the array. IOW, the return value is _not_ read-only.
> Whether you call the issue syntactical or not is just irrelevant and
> messing about with semantics.
You are mistaken. The issue is a syntactical one, not a functional one,
because a function call (currently) cannot occur on the left-hand side of an
assignment expression in PHP, *regardless* of the return value of function
to be called.
IOW, it does not make sense to say that "the return value is read-only" as
the function is *never* *called* and *no* return value is obtained in the
first place then. This is a rather important difference because syntax
errors are detected by the parser upon (JIT-)compilation already.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
|
|
|
Re: error message I don understand [message #174927 is a reply to message #174904] |
Mon, 18 July 2011 15:55 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
August Karlstrom wrote:
> On 2011-07-17 15:03, Jerry Stuckle wrote:
>> On 7/17/2011 8:55 AM, August Karlstrom wrote:
>>> It is a very easy mistake to do if you are used to saner programming
>>> languages in which `=' has the standard mathematical meaning (this
>>> symbol has been used in mathematics to denote equality for some 500
>>> years).
>> This isn't mathematics - it is programming, as people have told you
>> before. If you want mathematics, get a chalkboard.
>
> Don't be silly. There are several programming languages in which `='
> denote (surprise) equality.
And I have found all programs written in any of those programming languages
to be more difficult to maintain than the rest. One such language is
VBScript (which is particularly bad designed in other respects as well).
It is no coincidence that all modern higher-level programming languages make
a syntactical and not only a contextual difference between assignment and
comparison (`=' means comparison in a VBScript `If' statement, but
assignment in a standalone VBScript statement – why?), and that older ones
tend to do not (but speaking of math, even Pascal, arguably one of the older
ones, has `:=' and `=', respectively): Intelligent life is distinguished by
its ability to learn from past mistakes. For this is not only a maintenance
problem; it also makes compiling such source code more complicated as the
underlying grammar ends up being ambiguous.
I would always consider it a result of bad language design for a (built-in)
operator to have such very different meanings.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
|
|
|
Re: error message I don understand [message #174928 is a reply to message #174926] |
Mon, 18 July 2011 16:01 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Thomas 'PointedEars' Lahn wrote:
> Denis McMahon wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> In the end an oversimplified, wrong explanation. It is a syntactical
>>> requirement, not a functional one:
>>>
>>> $a = x();
>> Here you're assigning the return value of the function x() to the
>> variable $a.
>>
>>> $a[0] = 42;
>> Here you're writing to the variable $a (or rather, in this case, to an
>> element of the array that is variable $a).
>>
>> Neither of these is trying to assign (write) a value to the return value
>> of the function call.
>
> Yes, it is. The return value of the function is a one-element array, and
> with that assignment I am writing to the same memory area (or another memory
> area that holds a copy of the former's content) by changing the first
> element of the array. IOW, the return value is _not_ read-only.
>
>> Whether you call the issue syntactical or not is just irrelevant and
>> messing about with semantics.
>
> You are mistaken. The issue is a syntactical one, not a functional one,
> because a function call (currently) cannot occur on the left-hand side of an
> assignment expression in PHP, *regardless* of the return value of function
> to be called.
>
so you are saying that (x())[3]=7; is not allowable?
> IOW, it does not make sense to say that "the return value is read-only" as
> the function is *never* *called* and *no* return value is obtained in the
> first place then. This is a rather important difference because syntax
> errors are detected by the parser upon (JIT-)compilation already.
>
>
> PointedEars
|
|
|
Re: error message I don understand [message #174929 is a reply to message #174897] |
Mon, 18 July 2011 16:07 |
liebling.kreuzberg@gm
Messages: 10 Registered: July 2011
Karma: 0
|
Junior Member |
|
|
Thomas 'PointedEars' Lahn wrote:
> liebling(dot)kreuzberg(at)gmail(dot)com wrote:
>
>> Denis McMahon wrote:
>>> Consider:
>>>
>>> <?php
>>>
>>> function x()
>>> {
>>> return 5;
>>> }
>>>
>>> x() = 1;
>>>
>>> ?>
>>>
>>> although x() gives the value 5, it is not a variable that can be set, and
>>> so you can not assign (or write) a value (such as 1) to it.
>>>
>>> The php error message is saying that you can't assign (or write) a value
>>> to a function call, or in other words, the return value of a function
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> call is read_only data.
> ^^^^^^^^^^^^^^^^^^^^^^^
>> Thanks Dennis.
>>
>> Good addition to the explanation of Billy.
>
> In the end an oversimplified, wrong explanation. It is a syntactical
> requirement, not a functional one:
>
> function x()
> {
> return array(23);
> }
>
> $a = x();
>
> $a[0] = 42;
>
> /*
> * Array
> * (
> * [0] => 42
> * )
> */
> print_r($a);
>
> You would be well-advised to post under your real name, as it is customary
> in Usenet.
>
>
> PointedEars
Please leave the name I use to post with my responsibility.
I use a nickname and a REAL address as you can test.
Ohhh, what was your name? PointedEars? Ahhh, got it.
BR, Schimanski.
|
|
|
Re: error message I don understand [message #174930 is a reply to message #174905] |
Mon, 18 July 2011 16:11 |
liebling.kreuzberg@gm
Messages: 10 Registered: July 2011
Karma: 0
|
Junior Member |
|
|
Denis McMahon wrote:
> On Sun, 17 Jul 2011 09:00:53 -0400, Jerry Stuckle wrote:
>
>> Which has absolutely nothing to do with the problem the op had, or with
>> Dennis's explanation (which, btw, is one of the better ones I've seen
>> for this particular problem).
>
> Yeah, well part of what I was doing was trying to explain to the OP why
> PHP expresses the error in english the way it does, given that the OP
> might not be a native english speaker.
>
> It's very easy sometimes for us who are generally working with IT in our
> native languages to remember that for a lot of people, when they get an
> error message, their first problem with understanding the error is that
> they have to translate the error message into their own language, and
> things can get obscured by the translation.
>
> I'm sure I'm not the only one who would love to see T'PE'L give an
> explanation for the OPs original error message, but I've noticed that he
> seems to prefer making disparaging comments about other people's
> solutions and comments rather than making any contributions of his own,
> and on the rare occasions he does contribute, mostly he posts links to
> other people's work.
>
> I did see his attempt to correct me, but what he demonstrates is not what
> I said can't be done. Looks like he has comprehension as well as semantic
> issues ...
>
> Rgds
>
> Denis McMahon
Dennis:
Paragraph 1: you're absolutely right. My mothertongue is Dutch. (For the
others: try that one).
Paragraph 2: You're right again. I do need sometimes to translate to
understand the meaning of the error message. On the other hand, since
I'm able to define my own variables in MY language my variables seldom
confuse me.
Paragraph 3: I didn notice this, due to the short term I read here (a
few weeks).
BR, Schimanski.
|
|
|
Re: Nasty language semantics [message #174931 is a reply to message #174914] |
Mon, 18 July 2011 16:17 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
Robert Heller wrote:
> The Natural Philosopher wrote:
>> I want to know that '1.02' + '3.7' is reliably going to be either '4.72'
>> or '1.023.7', not implementation dependent, as I found in at least one
>> Javascript example.
To the best of my knowledge there is no such non-conforming ECMAScript
implementation. You (or the author of the example) must have been doing
something else wrong.
> Javascript's main problem here is using a common numerical operator (+)
> as a string operator as will AND allowing numbers to promoted (or
> demoted) to strings. Javascript *could* have picked a different
> operator for string concatenation, something less likely to cause
> ambigious interpretation.
There is no "Javascript"¹.
If you think about this, it would have been rather difficult for the
designer of JavaScript (and, as a consequence, the ECMAScript committee) to
choose another operator for concatenation that was widely accepted, given
that he needed the language to resemble Java (hence the name, changed from
LiveScript). They could not use today's PHP's `.', because that was already
taken for property access by Java (where PHP has the C++-ish `->' instead).
They could not use `<<' etc, because that was used for SHL/SHR already. And
they could not have skipped the implicit type conversion because the
language needed to be loosely typed (one design goal was a language that was
flexible, and easy to use, compared to Java).
I wouldn't mind if they chose C++/Python's optional whitespace operator for
concatenating string literals (that would have made writing/reading long
strings in source code considerably easier), and PHP's variable expansion
mechanism or Python's sprintf() mechanism (`%') for dealing with
"concatenation" of non-string values (IIRC, efforts for built-in string
templates in JavaScript 2.0 are underway). (`%' would have been ambiguous,
though, and might have meant a unwanted diversion from Java by introduction
of a `mod' operator instead.)
PointedEars
___________
¹ <http://PointedEars.de/es-matrix>
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
|
|
|
Re: Nasty language semantics (Was: error message I don understand) [message #174932 is a reply to message #174921] |
Mon, 18 July 2011 15:57 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Mon, 18 Jul 2011 09:22:58 +0100, Tim Streater wrote:
> I haven't used a goto since 1978 when I gave up writing FORTRAN. Oh
> wait, tell a lie, there was a period when I had to, since I was obliged
> to write in Pascal and there was no return statement. So I faked one by
> labelling the end of the function with 999: and then doing goto 999.
Something of Pyrrhic victory, some might say...
--
7. When I've captured my adversary and he says, "Look, before you kill
me, will you at least tell me what this is all about?" I'll say,
"No." and shoot him. On second thought I'll shoot him then say "No."
--Peter Anspach's list of things to do as an Evil Overlord
|
|
|
Re: error message I don understand [message #174933 is a reply to message #174929] |
Mon, 18 July 2011 16:27 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
liebling(dot)kreuzberg(at)gmail(dot)com wrote:
> Please leave the name I use to post with my responsibility.
If you leave me (and several others) the right to ignore you from now on …
> I use a nickname and a REAL address as you can test.
Your From *address* is not at issue.
> Ohhh, what was your name? PointedEars?
No, that is my nickname, to be found both in my signature and between my
first and last name in the From header. Which you could have noticed if
you were seriously interested in learning something here.
> Ahhh, got it.
I don't think so. You did not even consider my correction, so it would
seem, unfortunately, that I am wasting my time with you.
Score adjusted
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
|
|
|
Nasty language semantics (Was: error message I don understand) [message #174934 is a reply to message #174927] |
Mon, 18 July 2011 18:31 |
August Karlstrom
Messages: 16 Registered: October 2010
Karma: 0
|
Junior Member |
|
|
On 2011-07-18 17:55, Thomas 'PointedEars' Lahn wrote:
> August Karlstrom wrote:
>> Don't be silly. There are several programming languages in which `='
>> denote (surprise) equality.
>
> And I have found all programs written in any of those programming languages
> to be more difficult to maintain than the rest. One such language is
> VBScript (which is particularly bad designed in other respects as well).
That's because they have been badly designed in other respects as you
mention.
> It is no coincidence that all modern higher-level programming languages make
> a syntactical and not only a contextual difference between assignment and
> comparison
Yes, that is a good thing.
> I would always consider it a result of bad language design for a (built-in)
> operator to have such very different meanings.
Agreed. The assignment symbol should ideally be a left arrow but as we
all know it is not available on a standard keyboard or in the ASCII
character set. I think `:=' is a reasonable alternative.
August
--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
|
|
|
Re: Nasty language semantics [message #174935 is a reply to message #174934] |
Mon, 18 July 2011 19:29 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
August Karlstrom wrote:
> On 2011-07-18 17:55, Thomas 'PointedEars' Lahn wrote:
>> August Karlstrom wrote:
>>> Don't be silly. There are several programming languages in which `='
>>> denote (surprise) equality.
>> And I have found all programs written in any of those programming
>> languages to be more difficult to maintain than the rest. One such
>> language is VBScript (which is particularly bad designed in other
>> respects as well).
>
> That's because they have been badly designed in other respects as you
> mention.
NAK.
>> I would always consider it a result of bad language design for a
>> (built-in) operator to have such very different meanings.
>
> Agreed. The assignment symbol should ideally be a left arrow
NAK. As was said before, this is programming, not math.
> but as we all know it is not available on a standard keyboard or in the
> ASCII character set. I think `:=' is a reasonable alternative.
So are `=', `==' and `===', if only for keeping the well-established C
tradition (which makes it easier to learn yet another programming language,
mind you).
But there is another option: a compiler could disallow or warn about
assignment in conditional expressions if it was not obvious that this was
intended (as indicated by another pair of parentheses around the
assignment). AFAIK, the Java compiler (javac) and the Mozilla JavaScript
Validator include a switch to generate a warning. PHP's JIT-compiler SHOULD
also do this with the E_WARNING or E_COMPILE_WARNING bits set (but PHP
5.3.3-7+squeeze3 with Suhosin-Patch (cli) does not.)
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
|
|
|
Re: error message I don understand [message #174936 is a reply to message #174933] |
Mon, 18 July 2011 20:12 |
liebling.kreuzberg@gm
Messages: 10 Registered: July 2011
Karma: 0
|
Junior Member |
|
|
Thomas 'PointedEars' Lahn wrote:
> liebling(dot)kreuzberg(at)gmail(dot)com wrote:
>
>> Please leave the name I use to post with my responsibility.
>
> If you leave me (and several others) the right to ignore you from now on …
>
>> I use a nickname and a REAL address as you can test.
>
> Your From *address* is not at issue.
>
>> Ohhh, what was your name? PointedEars?
>
> No, that is my nickname, to be found both in my signature and between my
> first and last name in the From header. Which you could have noticed if
> you were seriously interested in learning something here.
>
>> Ahhh, got it.
>
> I don't think so. You did not even consider my correction, so it would
> seem, unfortunately, that I am wasting my time with you.
>
>
> Score adjusted
>
> PointedEars
Please, than do just that. Ignore me. The rest can decide for
themselves.
|
|
|
|