Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34929
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: void |
| Date | 2016-07-16 22:49 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <nmedlv$6im$1@dont-email.me> (permalink) |
| References | <void-20160716231330@ram.dialup.fu-berlin.de> |
On Sat, 16 Jul 2016 22:20:20 +0000, Stefan Ram wrote: > On several occassions I have observed that the compiler, javac, > has it's own vocabulary. For example, it uses words like »context« > or »symbol« that might not be used this way in the JLS. > > Another example I encountered today: > > The JLS does not seem to think of »void« as a »type«. It says: > > 8.4.5 Method Result > > The result of a method declaration either declares the type of value > that the method returns (the return type), or uses the keyword void to > indicate that the method does not return a value. > > (end of quotation). > > But for the compiler, it seems to be a »type«: > > Main.java:3: error: 'void' type not allowed here > java.lang.System.out.println( java.lang.System.out.println() ); }} > My guess is that the compiler does that because it has a single error message template, something like %s:%d: error '%s' type not allowed here so the least stupid thing it can use to describe the absence of arguments when they're expected is the work void which, in Java, always means an absence of an argument or return value. This is unlike C, where a function declared as "void free(void ptr)" means that free() takes an untyped pointer and returns an untyped pointer value. BUT note the void as a return value is ambiguous in C because it can also mean that nothing is returned by a function. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Re: void Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-16 22:49 +0000
Re: void Steven Simpson <ss@my.domain.invalid> - 2016-07-17 09:21 +0100
Re: void Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-17 18:36 +0000
Re: void Steven Simpson <ss@my.domain.invalid> - 2016-07-17 20:17 +0100
Re: void Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-17 22:15 +0000
Re: void Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-17 22:26 +0000
csiph-web