Totally agree.Originally posted by: kamper
If I made up coding standards that other people had to follow static imports would be one of the first things I would ban. Talk about a readability hazard![]()
Originally posted by: kamper
If I made up coding standards that other people had to follow static imports would be one of the first things I would ban. Talk about a readability hazard![]()
I'm not quite sure exactly what your little demo implies (not a c++ progammer) but I think you're dealing with package names there? In java you don't have to use package names in your code after the import statements unless you have two classes with the same unqualified name. As for the problem demonstrated in the op, it could be shortened by saying:Originally posted by: replicator
I see this as creating more problems than those solved. Not a very useful feature IMHO.
C# has a much cooler feature, you can alias your imports.
using MyAlias = MyCompany.Proj.Nested;
Originally posted by: kamper
What's really cool is Delphi's with blocks (not sure if it's inherited from pascal or not). You essentially create a new block, like an if, except that it "statically imports" an object(s) for the duration of the block so:
with (System.out) { //java syntax...
...println("hi"); // <-- resolves to System.out.println()
}
It's more useful because the import is limited to a readable size (not whole source file) and the syntactic savings are obvious if you have alot of work to do on a single object.
This is also one of those neat things you can do in VB.net (since it was found in the older VBs, MS brought it along for the ride) that you can't do in C#. I know that no one cares, but I thought I'd mention it anywayOriginally posted by: kamper
What's really cool is Delphi's with blocks (not sure if it's inherited from pascal or not). You essentially create a new block, like an if, except that it "statically imports" an object(s) for the duration of the block so:
with (System.out) { //java syntax...
...println("hi"); // <-- resolves to System.out.println()
}
It's more useful because the import is limited to a readable size (not whole source file) and the syntactic savings are obvious if you have alot of work to do on a single object.
I won't pretend to know the exact Delphi implementation, but the concept is something like this.Originally posted by: amdfanboy
Originally posted by: kamper
What's really cool is Delphi's with blocks (not sure if it's inherited from pascal or not). You essentially create a new block, like an if, except that it "statically imports" an object(s) for the duration of the block so:
with (System.out) { //java syntax...
...println("hi"); // <-- resolves to System.out.println()
}
It's more useful because the import is limited to a readable size (not whole source file) and the syntactic savings are obvious if you have alot of work to do on a single object.
Sweetness
Does it imply that everything is in the package or does it work like an import statement?
Originally posted by: Kilrsat
I won't pretend to know the exact Delphi implementation, but the concept is something like this.Originally posted by: amdfanboy
Originally posted by: kamper
What's really cool is Delphi's with blocks (not sure if it's inherited from pascal or not). You essentially create a new block, like an if, except that it "statically imports" an object(s) for the duration of the block so:
with (System.out) { //java syntax...
...println("hi"); // <-- resolves to System.out.println()
}
It's more useful because the import is limited to a readable size (not whole source file) and the syntactic savings are obvious if you have alot of work to do on a single object.
Sweetness
Does it imply that everything is in the package or does it work like an import statement?
Old way:
SomeItem.method1();
SomeItem.method6();
otherMethod(someItem.parameter57);
New way:
with (SomeItem) {
....method1();
....method6();
....otherMethod(parameter57);
}
Its not so much as importing a package as it is declaring to the compiler that if it runs into an unknown reference that it should check, in this case, SomeItem to see if it is there. If it is, use that one.
