July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote:
> Walter Bright wrote:
>> Not exactly what you're after, but consider the Java hello world program:
>>
>> class HelloWorldApp {
>> public static void main(String[] args) {
>> System.out.println("Hello World!");
>> }
>> }
>>
>> There's a reason for everything there, but it's a little off-putting.
>> Consider the D version:
>>
>> import std.stdio;
>>
>> void main() {
>> writefln("Hello World!");
>> }
>
> Changing the language syntax so that imports are private by default does
> not change anything in either of those examples.
True. But what I think goes too far is requiring hello world to look like:
import std.stdio;
public void main() {
std.stdio.writefln("Hello World!");
}
It's not like it's wrong to design D that way, it's just off-putting. Simple things should be simple.
|
July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote: > Jari-Matti Mäkelä wrote: >> Walter Bright wrote: >>> Not exactly what you're after, but consider the Java hello world program: >>> >>> class HelloWorldApp { >>> public static void main(String[] args) { >>> System.out.println("Hello World!"); >>> } >>> } >>> >>> There's a reason for everything there, but it's a little off-putting. Consider the D version: >>> >>> import std.stdio; >>> >>> void main() { >>> writefln("Hello World!"); >>> } >> >> Changing the language syntax so that imports are private by default does not change anything in either of those examples. > > True. But what I think goes too far is requiring hello world to look like: > > import std.stdio; > > public void main() { > std.stdio.writefln("Hello World!"); > } > > It's not like it's wrong to design D that way, it's just off-putting. Simple things should be simple. Agreed. Although I don't think anyone particularly was suggesting that it should be a default. According to <http://www.prowiki.org/wiki4d/wiki.cgi?ImportConflictResolution> a majority of active members only want to extend the import syntax so that old programs would work exactly as they do now and new programs would have better control over their namespaces. The 'static import' + some aliasing would be more than enough to fix this but many coders are so lazy (including me) they want import to support aliasing directly. ;) Making the imports private wouldn't break any existing tutorial code either since it requires at least two user modules for private imports to have any effect. Most code snippets I've seen feature only one. -- Jari-Matti |
July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> True. But what I think goes too far is requiring hello world to look like:
>
> import std.stdio;
>
> public void main() {
> std.stdio.writefln("Hello World!");
> }
>
> It's not like it's wrong to design D that way, it's just off-putting.
It's like going to the doctor, and he tells you you should eat whole wheat bread instead of white bread. Of course, he's right. His reasoning is sound, and backed by solid scientific evidence. But you just like white bread better, and since the grocery stores are well stocked with white bread, it obviously sells well. Any baker wanting to sell bread should pay attention <g>.
But the stores also have a line of whole wheat, for those that are willing to eat what's good for them.
|
July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote: > Although I don't think anyone particularly was suggesting that it should be a default. According to <http://www.prowiki.org/wiki4d/wiki.cgi?ImportConflictResolution> a majority of active members only want to extend the import syntax so that old programs would work exactly as they do now and new programs would have better control over their namespaces. The 'static import' + some aliasing would be more than enough to fix this but many coders are so lazy (including me) they want import to support aliasing directly. ;) I have to admit that 'static import' syntax has one advantage over #4 on that wiki. No-one has come up yet with an elegant way to provide only FQN access with the 'as'-syntax. Can't we have both. :) -- Jari-Matti |
July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | On Fri, 14 Jul 2006 11:54:53 -0700, Jari-Matti Mäkelä <jmjmak@utu.fi.invalid> wrote:
> Jari-Matti Mäkelä wrote:
>> Although I don't think anyone particularly was suggesting that it should
>> be a default. According to
>> <http://www.prowiki.org/wiki4d/wiki.cgi?ImportConflictResolution> a
>> majority of active members only want to extend the import syntax so that
>> old programs would work exactly as they do now and new programs would
>> have better control over their namespaces. The 'static import' + some
>> aliasing would be more than enough to fix this but many coders are so
>> lazy (including me) they want import to support aliasing directly. ;)
>
> I have to admit that 'static import' syntax has one advantage over #4 on
> that wiki. No-one has come up yet with an elegant way to provide only
> FQN access with the 'as'-syntax. Can't we have both. :)
>
Really?
import spec.lib.spec as spec.lib.spec;
Doesn't that work for you?
I think all this has been pretty thoroughly covered, Jari-Matti.
-JJR
|
July 14, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | John Reimer wrote:
> On Fri, 14 Jul 2006 11:54:53 -0700, Jari-Matti Mäkelä <jmjmak@utu.fi.invalid> wrote:
>
>> Jari-Matti Mäkelä wrote:
>>> Although I don't think anyone particularly was suggesting that it should be a default. According to <http://www.prowiki.org/wiki4d/wiki.cgi?ImportConflictResolution> a majority of active members only want to extend the import syntax so that old programs would work exactly as they do now and new programs would have better control over their namespaces. The 'static import' + some aliasing would be more than enough to fix this but many coders are so lazy (including me) they want import to support aliasing directly. ;)
>>
>> I have to admit that 'static import' syntax has one advantage over #4 on that wiki. No-one has come up yet with an elegant way to provide only FQN access with the 'as'-syntax. Can't we have both. :)
>>
>
>
> Really?
>
> import spec.lib.spec as spec.lib.spec;
>
> Doesn't that work for you?
Of course :)
|
July 15, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | In article <1dqjwdjjptjso.kw68mtrh7ba9.dlg@40tude.net>, Derek Parnell says... > >On Thu, 13 Jul 2006 10:22:41 +0300, Georg Wrede wrote: > >> >> I can, however, see this: >> >> import std.stdio as io; >> >> void main() { >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> io.writefln("Hello World!"); >> } > >Just half joking, but what you can do even now is this ... > > import std.stdio; > alias std.stdio.writefln w; > > void main() { > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > w("Hello World!"); > } And what about the with keyword ? : import std.stdio as io; : : void main () : { : with ( io ) : { : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : writefln ( "Hello World!" ); : } : } Any thoughts about it ? |
July 15, 2006 Re: Import concerns revisited | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rémy Mouëza | On Sat, 15 Jul 2006 10:39:42 +1000, Rémy Mouëza <ray.jay.ay.moueza@DoNtSpAm.gmail.com> wrote: > And what about the with keyword ? Because we don't know what the 'with' is referring to ... import std.stdio as io; void main () { with ( io ) { writefln ( somedata ); } } Is the 'io' a prefix to 'writefln' or 'somedata'? How would the human reader know that? -- Derek Parnell Melbourne, Australia |
Copyright © 1999-2021 by the D Language Foundation