www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - other keywords[as,throw]

reply cortigenb6 yahoo.com writes:
D is great but i ask if you can add these key words [as,throws]
[as] as in delphi make a checked typecast [objref as classref]
and [throws] as in java with which we can raise an exception 
very easily in java methods
thanks in advance

kortex
Jul 20 2005
parent reply Mike Capp <mike.capp gmail.com> writes:
In article <dbmlp5$126u$1 digitaldaemon.com>, cortigenb6 yahoo.com says...
D is great but i ask if you can add these key words [as,throws]
[as] as in delphi make a checked typecast [objref as classref]
work already.
and [throws] as in java with which we can raise an exception 
very easily in java methods
"throw" is already a D keyword and raises an exception. "throws" is something quite different - it's in Java to support exception specifications, which are now generally acknowledged to have been a bad idea. cheers Mike
Jul 20 2005
parent reply cortigenb6 yahoo.com writes:
thanks Mike
but why i want these keywords?!!! because i am a javanese man
and i really want to tranform a lot of java codes to d 
and im thinking for something like awt,swing for java
so deficient keywords like [throws ,instanceof,boolean]
make my dream a nightmare
i know with [D] we can do every thing as we like but as 
a lazy javanese programmer i need these keywords to make
my life easy and make me smile again
Jul 23 2005
parent reply Stefan <Stefan_member pathlink.com> writes:
In article <dbum4n$19l5$1 digitaldaemon.com>, cortigenb6 yahoo.com says...
thanks Mike
but why i want these keywords?!!! because i am a javanese man
and i really want to tranform a lot of java codes to d 
and im thinking for something like awt,swing for java
AWT, Swing?? And that's your only problem? Man, good luck ...
so deficient keywords like [throws ,instanceof,boolean]
They are not "deficient", they are missing - so what?. - boolean is bool (or bit), - "if (o instanceof x)" is "if (cast(x) o)" - throw is throw - throws: just drop it from the method signature, D has no checked exceptions. (For what it's worth I'm also 'javanese' and I principally like the concept of checked exceptions, but the Java API has just gone overboard with these in too many spots - 'javax.transaction.UserTransaction' any one?) At least, I don't see how that will hinder you from from converting Java sources to D. - "as" has never been a Java 'keyword' (or something else recognized by javac).
make my dream a nightmare
i know with [D] we can do every thing as we like but as 
a lazy javanese programmer i need these keywords to make
my life easy and make me smile again
Well, you're perhaps just too lazy ;-). Your "missing keywords" will very likely be the least problem when you're going to convert Java sources to D - most of them could be handled by simple string replacement or a slightly more advanced regexp algorithm. So I'd say: Wake up, D is not Java! You'll have to do some work on your own. Best regards, Stefan
Jul 23 2005
parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
Stefan wrote:
 In article <dbum4n$19l5$1 digitaldaemon.com>, cortigenb6 yahoo.com says...
make my dream a nightmare
i know with [D] we can do every thing as we like but as 
a lazy javanese programmer i need these keywords to make
my life easy and make me smile again
Well, you're perhaps just too lazy ;-). Your "missing keywords" will very likely be the least problem when you're going to convert Java sources to D - most of them could be handled by simple string replacement or a slightly more advanced regexp algorithm. So I'd say: Wake up, D is not Java! You'll have to do some work on your own. Best regards, Stefan
I remember someone was writing a tool to convert java code to d. I also remember that inner classes were speically added to d to ease that task.
Jul 24 2005