July 12, 2006 Re: Import proposals (Ideas) | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | ons 2006-07-12 klockan 10:25 -0700 skrev BCS: > jcc7 wrote: > > > > > > I'm just not a big fan of using with for this since it seems like importing to me. > > > > "with(module fooTooLong)" would be somewhat better, but I think "import" should be there. How about this? > > > > # import select fooTooLong > > # { > > # alias reallyTooLong tooShort; /* alias */ > > # alias reallyTooLong2 tooShort2; /* alias 2 */ > > # alias notReallyTooLongAtAll notReallyTooLongAtAll; /* No alias */ Seems redundant to have to type "notReallyTooLongAtAll" twice though. Just declaring which symbols you are interested in should be enough, with the option of declaring aliases at the same time for convenience. Also, I don't see the point of adding a keyword like "select" in all of it. I think it is pretty clear whats going on if import is followed by a block as opposed to just a module path and name: import mypackage.mymodule; where the whole module is imported. > > # } > > > > or if you just want to import one it'd be something like this: > > > > import select std.string.replace alias replace; > > > > or maybe even this if it's not being renamed... > > > > import select std.string.replace; > > > > I think there's a really good syntax in here somewhere. I'm just not sure what it is yet... > > > > jcc7 > > Yeah, that "with" doesn't look to good. OTOH that "select" looks kind of funny also. I think just switching to the "alias <name> [<name>];" syntax would be best. IIRC all {} block use ";" as a separator, so it would be more consistent than a comma separated list. Well, enums use commas. I think an import block somehow seems more related to an enum than, say, a struct. It is just a declaration of names/symbols, not types. /Anders |
July 12, 2006 Re: Import proposals (Ideas) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders Runesson | In article <1152731324.8336.9.camel@localhost>, Anders Runesson says... > >ons 2006-07-12 klockan 10:25 -0700 skrev BCS: >> jcc7 wrote: >> > >> > >> > I'm just not a big fan of using with for this since it seems like importing to me. >> > >> > "with(module fooTooLong)" would be somewhat better, but I think "import" should be there. How about this? >> > >> > # import select fooTooLong >> > # { >> > # alias reallyTooLong tooShort; /* alias */ >> > # alias reallyTooLong2 tooShort2; /* alias 2 */ >> > # alias notReallyTooLongAtAll notReallyTooLongAtAll; /* No alias */ > >Seems redundant to have to type "notReallyTooLongAtAll" twice though. Just declaring which symbols you are interested in should be enough, with the option of declaring aliases at the same time for convenience. > >Also, I don't see the point of adding a keyword like "select" in all of it. Oops. I've been looking at too much Visual Basic code. I was thinking that "select" was already a keyword in D. And "switch" doesn't sound right at all. Oh, well. I guess we don't need a keyword there. jcc7 |
Copyright © 1999-2021 by the D Language Foundation