Thomas 'PointedEars' Lahn wrote:
> Scott Sauyet wrote:
>> John Harris wrote:
>>> Scott Sauyet wrote:
>>> <snip>
>>>> <
http://scott.sauyet.com/Javascript/Demo/2013-05-27a/>
>>>> <
http://scott.sauyet.com/Javascript/Demo/2013-05-27b/>
>
>>>> In all browsers I tested, the programs displayed different behavior,
>>>> even though the two programs are identical except that one expression
>>>> has been replaced by an equivalent one in the second.
>>> <snip>
>
>>> Name the functions in the two examples f and g to lessen the
>>> confusion.
>
>> That would only confuse the point. The point is that the only
>> difference between the two programs is the substitution of `0` in the
>> second for the equivalent `+!1` in the first. Nonetheless the two
>> programs have different behavior. Making an additional change by
>> changing the name of the function would muddy the waters.
>
> You are the one who is muddying the waters here.
>
> The point is that you continue to fail to differentiate between
>
> A) an expression
>
> and
>
> B) the string representation of the function that contains it.
No, as I've demonstrated repeatedly, I understand the difference.
However, even though the two programs I supplied differ only in one
equivalent expression, they have different behavior.
Stipulating the definition of equivalent expressions as you've
presented it, if we define Document A as the one residing at
<
http://scott.sauyet.com/Javascript/Demo/2013-05-27a/>
and Document B as the one residing at
http://scott.sauyet.com/Javascript/Demo/2013-05-27b/>
The argument, in excruciating detail, proceeds as follows:
1. Document A and Document B differ only on line 9.
2. The difference on line 9 starts at column 29.
3. That difference falls inside a client-side program spanning lines
7 - 18. These two distinct programs we will label Program A
and Program B, respectively.
4. The difference from Program A to Program B can be described as
the deletion of the characters "+!1" and the insertion of the
character "0".
5. At character 29 of line 9, an expression is allowable.
6. "+!1" is a legal expression.
7. "0" is a legal expression.
8. "+!1" and "0" are equivalent expressions.
9. Hence Program A and Program B differ only in the substitution of
equivalent expressions.
10. Loading Document A and Document B into Chrome 27.0.1453.94 (*)
yield differing output.
11. That differing output is the result of the differences between
Program A and Program B.
12. Therefore, two programs that differ only in the substitution of
equivalent expressions can yield differing output.
(*) Feel free to substitute another modern browser.
Can you accept this argument? If not, which is the first step you
reject? And why do you reject it?
From here, it's my *interpretation* that the definition supplied is
not particularly useful, especially in the context specified by the OP
of minifiers. Of course you're free to disagree with this
interpretation. But you're not free to twist my words to make it
sound as though I argued something I didn't and something I disagree
with, not without challenge.
> The expression is evaluated to the return value of the function by the
> *compiler/interpreter* not before the function is *called*; its equivalence
> to another expression in that context means that the evaluation of the
> expression for the return value results in the same (identical) value.
>
> In short, the return values of the functions are the same, therefore the
> expressions leading to the return values are (value-)equivalent and the
> functions are functional equivalent. The functions themselves are obviously
> not value-equivalent per se (as indicated by the possibility of different
> string representations),
None of this is in contention. I don't know how to make it clearer
that I agree about this.
> but then again nobody but you claimed they should.
I have not tried to suggest an alternative definition, if you notice.
I did not claim that value-equivalence (or any approximation thereof
related to serialization) is essential. I have simply stated that the
definition as presented, one which can be used fairly
straightforwardly for automated refactorings in many languages, is not
as useful for that task in ES languages. I have provided an example,
which you seem determined to ignore. Do you accept Statement 12 in
the list above? If so, we're down to a question of interpretation.
You can be very sanguine about what I see as a significant problem by
insisting that those who rely on function serialization are simply out
of luck. Or you can take my view, which is that the weak
specification for function serialization together with the actual
implementation of it in modern ES engines is a serious blow to anyone
trying to write a bulletproof minifier. But if you don't agree with
Statement 12, I'd really like to know why.
> It is that difference, and that change of context involved, that you fail to
> comprehend, and that you ignore so that you can make the knee-jerk statement
> of a “reduced usefulness” of the textbook definition of (expression)
> equivalence.
Which textbook?
And why are you characterizing it as a knee-jerk reaction? This is
the only time I've ever discussed this topic in this ng. It's not as
though I've been harping on it over the years.
>>> You are saying that when f() and g() are 'equivalent' expressions
>>> then f.toString() should be 'equivalent' to g.toString() for
>>> equivalence to be a useful concept.
>
>> Not at all.
>
> Yes, you are.
Please provide a quote to back that up. I believe I remember quite
well what I've argued. And it was never that. I don't think
expression equivalence, by any definition, is likely to useful in
light of the problems I've described. (This is something of a
rhetorical flourish. I think it can be useful up to a point. But I
think that the type of exceptions displayed by my example demonstrates
that there is a large hole in any Javascript minification technique
that depends upon expression equivalence.)
>> The real point is that the equivalence of expressions is less useful
>> in Javascript than in many other languages.
> ^^^^^^^^^^
> Utter nonsense, twofold. Assuming “Javascript” as a misnomer for
> “ECMAScript implementations”,
(In order to reduce the noise, I'm willing to cater to your
idiosyncrasy on this when our posts are mostly a dialog between you
and me, but this was a response to John's post, and I reverted to my
usual language. No apologies.)
> you of all people should know that those
> languages are not the only languages in which functions are first-class
> objects. It is negatively surprising to me how little you understand both
> ECMAScript implementations and pure functional programming languages, yet
> you are attempting to implement – unnecessarily – “functional programming”
> in ECMAScript.
Of course I understand that there are many languages with first-class
functions. I've worked with a number of them, and have been studying
several others. I find no relevance except for those that allow
programs direct access to (at least some reasonable approximation) of
the source code of their functions. I'm sure there are other
languages that do so, but I've not observed this in other languages
I've used. Do you know of other examples?
>> Automatic minification based upon it can break programs that take
>> advantage of this weird quirk of the language. Perhaps the only answer is
>> Thomas' assertion that, "ECMAScript programs which rely on function
>> serialization are deeply flawed." But this does mean that automated
>> minification can possibly wreak havoc with certain code.
>
> Yes, and it means that you have still not understood the not-that-difficult
> concept of equivalence (of expressions in a computer program).
How does that follow?
>>> The equivalence of expressions is not the same as the equivalence of
>>> objects.
>
>> Shame on you; I think you've been listening to Thomas. :-) […]
>
> How many people explaining to you that you are wrong does it take before you
> can see that you are wrong?
Argumentum ad populum, now? From the man who's ever standing alone
arguing with everyone about the use of the term "Javascript"? What
could this world be coming to?
It would certainly take more than the "arguments" you've been
presenting, mainly trying to claim I'm saying something I'm not and
that I don't understand something I do.
>| Have you never, even once, considered the possibility that someone who
>| disagrees might understand the subject in as much depth as you do and
>| still have reached a different conclusion?
> – Scott Sauyet in
> <
news:ed180bb2-f6be-48dc...@h5g2000vbg.googlegroups.com>
>
> Probably you are either not smart enough for this, or you are trolling.
Actually I'm just waiting for you to come to even a modicum of
understanding about something very basic. Maybe it's a forlorn hope.
One of my first dialogs with you in this ng had the same quality. You
insisted over many posts that Rice's Theorem implied something that
Lasse Nielsen and I and the OP all disagreed with. It took many
posts, it seemed, before you stopped simply arguing and actually
listened, at which point you said:
| Apparently there has been a gross misunderstanding here. Of course
| what you describe is possible. I had no intention of denying
that.
- Thomas Lahn in <news:1566943.A...@PointedEars.de>
I'm still waiting for the comparable moment in this thread. I really
think you've got it in your head that I'm arguing something I'm not,
and you haven't been able to read what I actually wrote to see that it
is quite different.
-- Scott