JSON extracting data

S

Scott Sauyet

Moving what could have been an internal variable
declaration into a formal parameter is moving aspects that could be
entirely internal onto the public API.

It looks as though I unintentionally opened a can of worms here. The
original code I was questioning had to do with an anonymous function
that was immediately executed. There is really no public API
available:

(function(myVar) {
// define and use myVar
})();

The answer I got was that there is no advantage to this syntax; it's
simply the preference of the person who posted it. While I don't
share
this preference, I have no objection to it either. And I still
haven't
learned any arcane tricks! :)

-- Scott
 
T

Thomas 'PointedEars' Lahn

Scott said:
It looks as though I unintentionally opened a can of worms here.

So you have recognized that this is a discussion group after all?
The original code I was questioning had to do with an anonymous function
that was immediately executed. There is really no public API
available:

(function(myVar) {
// define and use myVar
})();

The assumption can be made that those who are not aware of the possible side
effects would do it regardless what the function is. Hence the points made.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Scott said:
It looks as though I unintentionally opened a can of worms here.

So you have realized that this is a discussion group after all?
The original code I was questioning had to do with an anonymous function
that was immediately executed. There is really no public API
available:

(function(myVar) {
// define and use myVar
})();

The assumption can be made that those who are not aware of the possible side
effects would do it regardless what the function is. Hence the points made.


PointedEars
 
J

Jorge

(...perfect, very well said, and wonderfully written stuff...)

I am not a supporter of issuing programmers with absolute injunctions;
if someone understands what they re doing they should also be in a
position to make up their own mind about things on an informed basis.
But my judgment of this practice is; no significant benefits, plus the
introduction of an otherwise avoidable potential for mistakes that may
have negative consequences.

Negative consequences... in the rare chain of events, if and only if :

1.- Some caller -unexpectedly- passes a value in that parameter
position,
2.- AND, the value passed is !== undefined,
3.- AND, the local-var/now-parameter is not initialized before use in
the function's body,
4.- AND, the function's result depends critically on that particular
local-var/now-parameter being undefined on entry,
5.- AND, the value passed instead is different enough to undefined so
as to yield a different result,
6.- AND, the different result obtained can be considered a "negative
consequence".
 
J

Jorge

The assumption can be made that those who are not aware of the possible side
effects would do it regardless what the function is.  Hence the points made.

Also, the assumption can be made that those who are not aware of the
possible side effects of using an(y) uninitialized vars will sooner or
later discover it.
 
S

Scott Sauyet

So you have realized that this is a discussion group after all?

I'm curious. Did you *mean* that to sound so patronizing?

Although I am new to clj, I started in USENET in the early 1990s. I
know that discussions often veer off in unusual directions; heck,
this thread started as a discussion on the use of JSONP. A comment
like "Oops, I seem to have opened a can of worms," is, I believe,
widely recognized as shorthand for something like this:

"The discussion has gone in a direction I didn't intend, and has
turned more controversial than expected. I'm sorry to have
brought to this group the rancor recently seen. And I'd like to
refocus on a less controversial aspect."

I'm by no means worried about discord. I cut my USENET teeth in
alt.atheism, which was at the time one of the most disputatious
forums around. But my initial question was not one which I expected
to cause any strife. I really thought I might learn some useful
trick. As it turned out, there was no useful trick involved, only a
style that Jorge uses and which you condemn.

I don't recommend Jorge's style. But when I point out that when
used the way he did here, it has none of the problems that you and
Richard Cornford mention, you say:

The assumption can be made that those who are not aware of the possible side
effects would do it regardless what the function is.  Hence the points made.

Remember that Jorge was suggesting some code to paste into a JS
console. To assume that anyone would use this one-off code as a
model for their own JS coding style seems far-fetched. OF course
"the assumption can be made", but it doesn't strike me as a likely
thing or something to get particularly worked up about.

-- Scott
 
T

Thomas 'PointedEars' Lahn

Jorge said:
Also, the assumption can be made that those who are not aware of the
possible side effects of using an(y) uninitialized vars will sooner or
later discover it.

Or never. If you want to propose rather ill-advised code style and let
others suffer the consequences, fine. But don't expect more competent
bystanders to let you do so uncommented, or complain about it when they do.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Scott said:
I'm curious. Did you *mean* that to sound so patronizing?

I do not know how a *written* question *sounds* to you, nor do I care. It
was a rhetorical question anyway, so while your answer was informative and
is appreciated, I did not consider it necessary.
Although I am new to clj, I started in USENET in the early 1990s. I
know that discussions often veer off in unusual directions; heck,
this thread started as a discussion on the use of JSONP.

Yes, somebody should have changed the Subject header long ago ...
A comment like "Oops, I seem to have opened a can of worms," is, I
believe, widely recognized as shorthand for something like this:

"The discussion has gone in a direction I didn't intend, and has
turned more controversial than expected. I'm sorry to have
brought to this group the rancor recently seen. And I'd like to
refocus on a less controversial aspect."

But there is little discussion without controversy. Be careful what you
wish for.
I'm by no means worried about discord. I cut my USENET teeth in
alt.atheism, which was at the time one of the most disputatious
forums around. [...]

AIUI, alt.* does not belong to Usenet, though.
Remember that Jorge was suggesting some code to paste into a JS
console. To assume that anyone would use this one-off code as a
model for their own JS coding style seems far-fetched. OF course
"the assumption can be made", but it doesn't strike me as a likely
thing or something to get particularly worked up about.

I do not know what you mean by "worked up". Anyhow, seeing ridiculously
stupid things like jQuery going on for *years*, should we not hope for the
best, but must we not expect the worst from the casual reader? A little
explanation does not hurt anyone (except if one does want to take it
personally), and is certainly better than letting people in the dark.


F'up2 poster

PointedEars
 
J

Jorge

Or never.  If you want to propose rather ill-advised code style and let
others suffer the consequences, fine.

There are consequences to suffer due to ill-advised code that depends
on uninitialized vars. Once you get it, you'll understand that neither
that nor your "code injection" fairy tales have anything to do with my
style whatsoever.
But don't expect more competent
bystanders to let you do so uncommented, or complain about it when they do.

Hmm, expectations. What should one expect -or not- from self-
proclaimed "more competent" bystanders ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,082
Messages
2,570,586
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top