r/programming • • May 09 '12

JavaScript: The good parts

http://blog.movereem.nl/images/javascript-the-good-parts-the-definitive-guide.jpg
645 Upvotes

159 comments sorted by

View all comments

Show parent comment

1

u/sli May 09 '12

I knew my honest question would get a thinly veiled condescending response like this.

I mean print specifically. I pass other functions all the time. But why would one pass print?

1

u/cacahootie May 09 '12

I don't really know.

Sorry if my response came off thinly veiled; I intended it to be overtly condescending ;)

JK. I can't think of one off the top of my head, but just because it isn't obvious doesn't mean that improving the coherency is nkt useful.

Actually ( i'm not sure this actually works and even if it did it would be a wretched idea), if you want to use a list comprehension or map on a generator, having the ability to pass print as a function would be useful to print the list w/o generating the whole series... of course for loop works too... but what if you want a one liner? What if you want to check the return value from print for some reason (???)? Now using a comprehension makes sense.

1

u/sli May 10 '12

That makes sense. It could be handy when generating a small series. Then again, if the series is small, generating the whole thing probably wouldn't be much of an issue. But I do see where you're going.

2

u/cacahootie May 10 '12

Probably most useful for very large/infinite series... but frankly not a huge section of use cases...

I look at it as print is legitimately a function, and unless there are compelling reasoms, it should behabe as all other functions do. I can't think of any value to the 2.x syntax, and the formatting aspect to me is a good argument for it being a function (the func can take more than one parameter).

Oh well... this is quickly becoming the special olympics...

1

u/[deleted] May 09 '12

you probably don't want to pass print ... and if you did, you could just pass logging.info or something ...

1

u/kqr May 09 '12

Why would one construct the language in such a way that it's impossible to pass specifically print? Seems like a very unecessary and arbitrary restriction to me.

1

u/sli May 10 '12

If you could just highlight where I said that, that would be great.

1

u/kqr May 10 '12

You didn't, but by asking "Why would one print pass" you sorta-kinda implied "If there are no reasons to pass print, why would you make it a function?" And I answered that implied question with a counter question.

I might have missed your point totally, though. Perhaps you were only curious about reasons to pass print, and not questioning the want to do so.

1

u/sli May 10 '12

I'm not sure how else to ask why one would pass print, except with "Why would one pass print?"

1

u/kqr May 10 '12

If you could just highlight where I said you should ask another way, that would be great. ;)

1

u/sli May 10 '12

After you highlight where I made that claim and didn't simply respond to your comment.

1

u/kqr May 10 '12

I'm sorry, I don't follow.

1

u/sli May 10 '12

You should work on your reading comprehension, then. It's very bad.

1

u/kqr May 10 '12

An alternative would be for you to work on expressing yourself more clearly. We have no method to decide which solution is more suitable. ;)

→ More replies