jashkenas / coffeescript

Unfancy JavaScript
https://coffeescript.org/
MIT License
16.49k stars 1.99k forks source link

Why not add 'void' as an alias for 'undefined'? #3646

Closed xyrius closed 9 years ago

michaelficarra commented 9 years ago

How about not?

edit: See below.

xyrius commented 9 years ago

I hope you are not trying to be funny, that we would be pretty sad.. It is still a question, please give me your best answer.

void is used in many great languages, and I am pretty sure I am not the only one who likes it more than undefined. If void freakes you out so much, please let us at least know why.

epidemian commented 9 years ago

@xyrius, it might be because usually void denotes an empty type. Functions of type void in C/C++/Java/whathaveyou don't return anything; you can't have a variable with a void value.

undefined in JS is different in that it is a value, so you can use it in places where a value is allowed: associated with a variable, as an element on an array, a value of a property, etc.

Besides, void already exists in JS/CS as an operator, that evaluates some expression and returns undefined.

xyrius commented 9 years ago

@epidemian, I assume undefined derives from void. But because we do not have a compiler in Javascript we cannot use it the same way as it is being used by typed languages. At runtime you have to have some value representing "no usable type here", so that value became undefined, and void(0) checks for that value. I never asked Brendan Eich about this, but it seems obvious to me that Javascript functions returning undefined by default is inspired by a C function returning void.

You said that void already exists in CS as an operator, indeed: error: reserved word "void". So, please tell me how I can use it.

epidemian commented 9 years ago

You said that void already exists in CS as an operator, indeed: error: reserved word "void". So, please tell me how I can use it.

Sorry, i was confused. I assumed void worked in Coffee the same way it works in JS. But it seems it doesn't.

xyrius commented 9 years ago

Here you are... I am still waiting for an answer from @michaelficarra. I hope he can put his ego aside for a moment and tell us something more intelligent and interesting about why not.

carlsmith commented 9 years ago

@xyrius -- I know it's frustrating when core dev dismiss your input without much consideration. It does feel a little insulting. It happened to me this morning too. Still, core dev have a lot to do. Every morning their inbox is filled with wacky proposals, often duplicates, and they have to deal with it. The reason @michaelficarra responded is because he's taken it upon himself to try and deal with today's backlog.

If you want a proposal to be taken seriously, you should really bike-shed it in some other forum, then come here with a case, community support and a summary of objections. No one does that in practice, so the system's broken. Try and remember this is much more frustrating for core developers than it is for us guys.

xyrius commented 9 years ago

Thank you Carl for your explanation.

If CS core dev's already reached that point of ignorance, than indeed it is futile to propose almost anything. Instead of insult, wipe and close, he maybe better use some default answer like: 'sorry, I have no time to get into this now.', and push it in a repository of unanswered questions.

About your suggestion on how to get your proposal be taken seriously: there is no guarantee that after all the preperation and effort to 'bike-shed' an idea, you won't get the same reply. It could quite possible take less time and effort to fork CS and do it yourself.

I get a strong feeling of doing CS core dev's a great pleasure to leave them alone, not bothering them. So I will stop giving any input, as I don't want to waste my time annoying other people. I will take CS for what it is, and thank them at least for the great work they do to make it better.

This was my very last post in this forum, one nuisance less hehe, bye all.

On Sat, Sep 20, 2014 at 2:04 PM, Carl Smith notifications@github.com wrote:

@xyrius https://github.com/xyrius -- I know it's frustrating when core dev dismiss your input without much consideration. It does feel a little insulting. It happened to me this morning too. Still, core dev have a lot to do. Every morning their inbox is filled with wacky proposals, often duplicates, and they have to deal with it. The reason @michaelficarra https://github.com/michaelficarra responded is because he's taken it upon himself to try and deal with today's backlog.

If you want a proposal to be taken seriously, you should really bike-shed it in some other forum, then come here with a case, community support and a summary of objections. No one does that in practice, so the system's broken. Try and remember this is much more frustrating for core developers than it is for us guys.

— Reply to this email directly or view it on GitHub https://github.com/jashkenas/coffeescript/issues/3646#issuecomment-56266023 .

michaelficarra commented 9 years ago

@xyrius I simply put as much effort in my response as you put into your proposal. It is not because I was tired or hurried. A proposal should include use cases, justification, and an overview of how the currently available features are failing them. The feature you're looking for, an analogue to the void operator, is entirely unnecessary. CoffeeScript's undefined keyword compiles to void 0, generating an undefined value, and simulating JavaScript's void operator is as simple as (X; undefined).

Please stop with the terrible attitude and wild assumptions about me.

carlsmith commented 9 years ago

@michaelficarra -- Sorry, I didn't mean to put words in your mouth there.

@xyrius -- If you did put the effort in, had strong support from the community and came here with that kind of authority, it's likely that CS decision makers would have long since familiarised themselves with the proposal. They'd be the ones in that forum who'd suggest moving your proposal to a PR, and would champion it.

It's also wrong to assume that your time is too valuable to spend on a proposal that may not be realised, so core dev should drop everything to consider it personally.

xyrius commented 9 years ago

@michaelficarra, Please have no hard feelings. Ask Jeremy if he designed this language with use cases, justifications, overviews etc.. for every single implementation thought he had on CS. CS would not exist following that path.

I guess I just don't fit into this, better do my own thing. That's why I leave this forum. My attitude is not that terrible, I just gave you my thanks for your great work on CS.

@carlsmith, I said "I don't want to waste my time annoying other people.", I didn't assume my time too valuable to spend on bla bla...

Thoughts, words, very tricky, programming proves that more than anything else.

All the best.

On Sat, Sep 20, 2014 at 4:05 PM, Carl Smith notifications@github.com wrote:

@michaelficarra https://github.com/michaelficarra -- Sorry, I didn't mean to put words in your mouth there.

@xyrius https://github.com/xyrius -- If you did put the effort in, had strong support from the community and came here with that kind of authority, it's likely that CS decision makers would have long since familiarised themselves with the proposal. They'd be the ones in that forum who'd suggest moving your proposal to a PR, and would champion it.

It's also wrong to assume that your time is too valuable to spend on a proposal that may not be realised, so core dev should drop everything to consider it personally.

— Reply to this email directly or view it on GitHub https://github.com/jashkenas/coffeescript/issues/3646#issuecomment-56268779 .

carlsmith commented 9 years ago

No worries. I will just add, in my experience, people take that attitude at first and come round over time. I was pissed off about equality operators when I joint the community. It takes time to start to really appreciate the benefits of the conservative approach. When Jeremy wrote the language, it was just win or fail, no biggie. Now, he's responsible for a major programming language. His concerns evolved.

Hope to see you around.

jashkenas commented 9 years ago

Equality operators, eh?

carlsmith commented 9 years ago

I wanted a runtime function ripping out of underscore or something and an equals operator adding, so [] equals [] and {} equals {} would evaluate to true. It didn't happen.

xyrius commented 9 years ago

@carlsmith, sorry I became a bit edgy, I shouldn't have posted anyways as it was not my day for more reasons..

For those interested: I think undefined is awkward, and I don't like void in it's current form as the tricky evaluating function it is now in JS. I almost never see void being used in other (useful) ways than void 0. So, why not use void as undefined instead of not using it at all?

I truly believe void is semantically better than undefined because when you declare a variable undefined it is actually defined, only it's value is void. Besides, void reads, writes and feels better, for me at least.

void is undefined   # true would be great

setColor void, void, 180
# instead of
setColor undefined, undefined, 180

someVar = void
# instead of
someVar = undefined   
@someListener[ id ] = void
# instead of
@someListener[ id ] = undefined
jashkenas commented 9 years ago

Void \Void\, v. i. To be emitted or evacuated. --Wiseman.

Void \Void\, a. [OE. voide, OF. voit, voide, vuit, vuide, F. vide, fr. (assumed) LL. vocitus, fr. L. vocare, an old form of vacare to be empty, or a kindred word. Cf. {Vacant}, {Avoid}.]

  1. Containing nothing; empty; vacant; not occupied; not filled.

The earth was without form, and void. --Gen. i. 2.

I 'll get me to a place more void. --Shak.

I 'll chain him in my study, that, at void hours, I may run over the story of his country. --Massinger.

  1. Having no incumbent; unoccupied; -- said of offices and the like.

Divers great offices that had been long void. --Camden.

  1. Being without; destitute; free; wanting; devoid; as, void of learning, or of common use. --Milton.

A conscience void of offense toward God. --Acts xxiv. 16.

He that is void of wisdom despiseth his neighbor. --Prov. xi. 12.

  1. Not producing any effect; ineffectual; vain.

[My word] shall not return to me void, but it shall accomplish that which I please. --Isa. lv. 11.

I will make void the counsel of Judah. --Jer. xix. 7.

  1. Containing no immaterial quality; destitute of mind or soul. ``Idol, void and vain.'' --Pope.
  2. (Law) Of no legal force or effect, incapable of confirmation or ratification; null. Cf. {Voidable}, 2.

{Void space} (Physics), a vacuum.

Syn: Empty; vacant; devoid; wanting; unfurnished; unsupplied; unoccupied.

Void \Void\, n. An empty space; a vacuum.

Pride, where wit fails, steps in to our defense, And fills up all the mighty void of sense. --Pope.

Void \Void\, v. t. [imp. & p. p. {Voided}; p. pr. & vb. n. {Voiding}.] [OF. voidier, vuidier. See {Void}, a.]

  1. To remove the contents of; to make or leave vacant or empty; to quit; to leave; as, to void a table.

Void anon her place. --Chaucer.

If they will fight with us, bid them come down, Or void the field. --Shak.

  1. To throw or send out; to evacuate; to emit; to discharge; as, to void excrements.

A watchful application of mind in voiding prejudices. --Barrow.

With shovel, like a fury, voided out The earth and scattered bones. --J. Webster.

  1. To render void; to make to be of no validity or effect; to vacate; to annul; to nullify.

After they had voided the obligation of the oath he had taken. --Bp. Burnet.

It was become a practice . . . to void the security that was at any time given for money so borrowed. --Clarendon.


A beautiful word, but not something we should be changing at this point. Hopefully you don't need to be using undefined very much in your code. null is usually the one you actually want to program with — and an even groovier word than "void".

carlsmith commented 9 years ago

void would have been a better name for wontfix

xyrius commented 9 years ago

@jashkenas, thx for your time, we'll live without the void. Btw, thanks too for CS, it's awesome!

igl commented 9 years ago

Why is void a reserved word in CS? Why would i want to use null when typeof null is an object? Isn't the void function part of javascript and practically inaccessible in cs?

Thinking about it more: It's kind of fun that void is void in cs. (Thats the point right?)