www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - .NET from D

reply "John C" <johnch_atms hotmail.com> writes:
At least a couple of people were interested in using .NET from D. The 
attached example shows one way of doing it, without hosting the CLR.

Here's a taster:

    _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
    ICollection collection = com_cast!(ICollection)(arrayList);
    int index;
    collection.add(VARIANT(12345), index);

    VARIANT v;
    collection.get_Item(index, v);
    writefln(v.lVal);

Note that the attached files include only the bare minimum to get the 
example to run. I've not defined all the CLR types and some are merely 
placeholders. I've only tested this with .NET 2.0 (but it should work with 
1.0/1.1).

Enjoy. 


begin 666 clrtest.zip

M$+Y7ZG^85MHE0566YZDJ4E4$5*Q8L2W=`XLJ-YFT7CGVRG:V%+3_'3^:. GE
MP($+ATCV^)MOOGG8*416,H242EFJ)&52H]+C?J_?H\6]D+H^2?:49V)O5J(8

M1B <*%>:\!1!Y+ X*(U%,A.,8:JIX"J92DD.EU1IZ[BN=T#JU01J:Y(ZVJO-

MU(2U/;(,\9%B?V],.H^&)W#Q+;_5DS=PILR"#T

M(<+F2!\,AKU>MD(%2"> I[#M8LU.P?EYD^NW!H+-T7P9?A]7%J-[FF5^T'03
MMI-&C*5/S'FTFE[/IY^6T?,7+U^]CD>>)$CQ8JS+!!;KJX^-D)XM%277XV!S

MKK07*<LPZPAW9=FB7L\-,G*U&,'#WPJW+%_/Z+>NX(HO82O"`NECR,!HO4$H
MK+Q2N9&>,B92?Q= "_#WW
MHST7GN=_G(=_V&C5;?3&E?&/O7XK^!/W &WM  K(S;OG!K7=V_:+Z#O3I*YP
M+JEK9$ 41E7,.F)XA]N0(V FOG :?EO^3*(N)8=G9O/X"U!+`P04````" `M

MTW:#Q84BRZUNY<>1Y72+BXM D>5$6UD2],ACS^E_O^2\-".-TW2WN ':S) <
MDD-R2,[8.3SX^6<RSVL2Y;LBK)/;-":/27U/JGIS$IT\)MDF?ZQ.`'MX<'BP
MRS<-$$1)63:5CKY$?%&&=[MPD":W0_)3GL9GXQ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5Q."!?MF2=>H$&U"TQP.F5T* 2Y0<T


M/Q0J^ZQ1IW0=9L&F"0HX`%OV $WR\/K'_P)02P,$% ```` `V%9Y,]IGSL$W

M">;EBG?.+W+*S$L)R0\JS2O)S$UUK7 P,E&P5< 4!P!02P,$% ```` `Z%9Y



MC'DS5[ `+7$"``!,!P``"0`````````!`" `````````8VQR=&5S="YD4$L!
M`A0`% ```` `+8MY,_.X\&PT#P``TC<```4``````````0` ````F (``&-O

M[Q$``&-L<BYD4$L!`A0`% ```` `V%9Y,]IGSL$W````10````L`````````
M`0` ````12 ``&US8V]R964N9&5F4$L!`A0`% ```` `Z%9Y,SM^1U)>````
M``8```L```````````` ````I2 ``&US8V]R964N;&EB4$L%! `````%``4`
*#P$``"PA````````
`
end
Nov 25 2005
next sibling parent reply Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
John C wrote:
 At least a couple of people were interested in using .NET from D. The 
 attached example shows one way of doing it, without hosting the CLR.
 
 Here's a taster:
 
     _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
     ICollection collection = com_cast!(ICollection)(arrayList);
     int index;
     collection.add(VARIANT(12345), index);
 
     VARIANT v;
     collection.get_Item(index, v);
     writefln(v.lVal);
 
 Note that the attached files include only the bare minimum to get the 
 example to run. I've not defined all the CLR types and some are merely 
 placeholders. I've only tested this with .NET 2.0 (but it should work with 
 1.0/1.1).
 
 Enjoy. 
 
Very very interesting, i didn't know it was possible. But IMO too hard to use in real life.
Nov 25 2005
parent "John C" <johnch_atms hotmail.com> writes:
"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message 
news:dm7vvr$1njo$1 digitaldaemon.com...
 John C wrote:
 At least a couple of people were interested in using .NET from D. The 
 attached example shows one way of doing it, without hosting the CLR.

 Here's a taster:

     _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
     ICollection collection = com_cast!(ICollection)(arrayList);
     int index;
     collection.add(VARIANT(12345), index);

     VARIANT v;
     collection.get_Item(index, v);
     writefln(v.lVal);

 Note that the attached files include only the bare minimum to get the 
 example to run. I've not defined all the CLR types and some are merely 
 placeholders. I've only tested this with .NET 2.0 (but it should work 
 with 1.0/1.1).

 Enjoy.
Very very interesting, i didn't know it was possible. But IMO too hard to use in real life.
Quite. And indeed it is rare. But reasons do exist for wanting to run CLR code from unmanaged apps. There are some fairly large products that do so - Microsoft Office, SQL Server, Viruoso, DB2 and of course Visual Studio.
Nov 26 2005
prev sibling next sibling parent reply Chris <ctlajoie yahoo.com> writes:
On Fri, 25 Nov 2005 17:44:32 -0000, "John C" <johnch_atms hotmail.com>
wrote:

At least a couple of people were interested in using .NET from D. The 
attached example shows one way of doing it, without hosting the CLR.

Here's a taster:

    _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
    ICollection collection = com_cast!(ICollection)(arrayList);
    int index;
    collection.add(VARIANT(12345), index);

    VARIANT v;
    collection.get_Item(index, v);
    writefln(v.lVal);

Note that the attached files include only the bare minimum to get the 
example to run. I've not defined all the CLR types and some are merely 
placeholders. I've only tested this with .NET 2.0 (but it should work with 
1.0/1.1).

Enjoy. 
very nice proof of concept. I know others have various reasons for wanting to, but I personally have no interest in using .NET classes in D. I am however very interested in compiling D (there would have to be some slight deviations in the syntax) directly to MSIL. In fact I'm reading up on compiler design and experimenting with a toy language I created that compiles to MSIL. Soon hopefully I will understand enough to begin writing one for D. Chris
Nov 25 2005
next sibling parent Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
Chris wrote:
 I am however very interested in compiling D (there would have to be
 some slight deviations in the syntax) directly to MSIL. In fact I'm
 reading up on compiler design and experimenting with a toy language I
 created that compiles to MSIL. Soon hopefully I will understand enough
 to begin writing one for D.
 
Cool! Can't wait! :)
Nov 26 2005
prev sibling next sibling parent reply Manfred Hansen <manfred toppoint.de> writes:
Hello,

i found this link
https://mywebspace.wisc.edu/daaugustine/web/d/
from Deja Augustine

Manfed


Chris wrote:

 On Fri, 25 Nov 2005 17:44:32 -0000, "John C" <johnch_atms hotmail.com>
 wrote:
 
At least a couple of people were interested in using .NET from D. The
attached example shows one way of doing it, without hosting the CLR.

Here's a taster:

    _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
    ICollection collection = com_cast!(ICollection)(arrayList);
    int index;
    collection.add(VARIANT(12345), index);

    VARIANT v;
    collection.get_Item(index, v);
    writefln(v.lVal);

Note that the attached files include only the bare minimum to get the
example to run. I've not defined all the CLR types and some are merely
placeholders. I've only tested this with .NET 2.0 (but it should work with
1.0/1.1).

Enjoy.
very nice proof of concept. I know others have various reasons for wanting to, but I personally have no interest in using .NET classes in D. I am however very interested in compiling D (there would have to be some slight deviations in the syntax) directly to MSIL. In fact I'm reading up on compiler design and experimenting with a toy language I created that compiles to MSIL. Soon hopefully I will understand enough to begin writing one for D. Chris
Nov 26 2005
parent reply Chris <ctlajoie yahoo.com> writes:
On Sat, 26 Nov 2005 11:03:07 +0100, Manfred Hansen
<manfred toppoint.de> wrote:

Hello,

i found this link
https://mywebspace.wisc.edu/daaugustine/web/d/
from Deja Augustine

Manfed
Nice find! I don't want to get the old framework just to decompile that. I was able to look at the class structure in it though and it looks like he took the D frontend and changed for his compiler. Chris
Nov 26 2005
parent J C Calvarese <technocrat7 gmail.com> writes:
In article <ob9ho1hm8snvtl520anft0ei7p39bnkcvn 4ax.com>, Chris says...
On Sat, 26 Nov 2005 11:03:07 +0100, Manfred Hansen
<manfred toppoint.de> wrote:

Hello,

i found this link
https://mywebspace.wisc.edu/daaugustine/web/d/
from Deja Augustine

Manfed
Nice find! I don't want to get the old framework just to decompile that. I was able to look at the class structure in it though and it looks like he took the D frontend and changed for his compiler. Chris
Right. My understanding is that his compiler code was based on Walter's fontend. jcc7
Nov 26 2005
prev sibling next sibling parent reply "John C" <johnch_atms hotmail.com> writes:
"Chris" <ctlajoie yahoo.com> wrote in message 
news:h83go15mparb57e1f5d7uroprpo13seb0f 4ax.com...
 On Fri, 25 Nov 2005 17:44:32 -0000, "John C" <johnch_atms hotmail.com>
 wrote:

At least a couple of people were interested in using .NET from D. The
attached example shows one way of doing it, without hosting the CLR.

Here's a taster:

    _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
    ICollection collection = com_cast!(ICollection)(arrayList);
    int index;
    collection.add(VARIANT(12345), index);

    VARIANT v;
    collection.get_Item(index, v);
    writefln(v.lVal);

Note that the attached files include only the bare minimum to get the
example to run. I've not defined all the CLR types and some are merely
placeholders. I've only tested this with .NET 2.0 (but it should work with
1.0/1.1).

Enjoy.
very nice proof of concept. I know others have various reasons for wanting to, but I personally have no interest in using .NET classes in D. I am however very interested in compiling D (there would have to be some slight deviations in the syntax) directly to MSIL. In fact I'm reading up on compiler design and experimenting with a toy language I created that compiles to MSIL. Soon hopefully I will understand enough to begin writing one for D. Chris
It would seem there are several people in this group doing the same thing - would it not make sense to join forces to get a fully functional D.NET compiler out the door?
Nov 26 2005
next sibling parent Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
John C wrote:
 It would seem there are several people in this group doing the same thing - 
 would it not make sense to join forces to get a fully functional D.NET 
 compiler out the door? 
 
It would make a lot sense, maybe dmdfe would be a good start?
Nov 26 2005
prev sibling parent reply Chris <ctlajoie yahoo.com> writes:
On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
wrote:
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
Nov 26 2005
next sibling parent reply John Reimer <terminal.node gmail.com> writes:
Chris wrote:
 On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
 wrote:
 
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
Talk to Brad at dsource.org. I'm fairly certain he hosts any project that pertains to D, even if it isn't programmed in the D language itself. Example projects on dsource.org that are in other languages: eclipseD -- Java; plugin for Eclipse IDE H2D -- C++; C header to D module conversion tool DManager -- Delphi; D Project Manager And there are others. -JJR
Nov 26 2005
parent Chris <ctlajoie yahoo.com> writes:
On Sat, 26 Nov 2005 14:39:14 -0800, John Reimer
<terminal.node gmail.com> wrote:

Chris wrote:
 On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
 wrote:
 
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
Talk to Brad at dsource.org. I'm fairly certain he hosts any project that pertains to D, even if it isn't programmed in the D language itself. Example projects on dsource.org that are in other languages: eclipseD -- Java; plugin for Eclipse IDE H2D -- C++; C header to D module conversion tool DManager -- Delphi; D Project Manager And there are others. -JJR
I'll ask Brad then. I'd prefer to have it on dsource as long as he doesn't mind. Chris
Nov 26 2005
prev sibling next sibling parent Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
Chris wrote:
 On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
 wrote:
 
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway).
Well I started reading Build Your Own .NET Language and Compiler and Inside Microsoft .NET IL Assembler for a purpose of playing with the idea of writing a D.NET compiler but lack free time for this. But would be more than glad to help any way I can.
 Mine will be open source, 
great
 perhaps on sourceforge (I believe dsource is
 for D projects only). 
I think it could be on dsource because it is very D-related.
 If anyone knows where I should host it I'm open
 to suggestions. I prefer to use svn instead of cvs. 
svn is IMO a better choise.
Nov 26 2005
prev sibling parent reply J C Calvarese <technocrat7 gmail.com> writes:
In article <d1mho11g54e2iv8i2fovn5rb1as7eoel6s 4ax.com>, Chris says...
On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
wrote:
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
I think to be eligible for dsource a project needs to be open source and either using D or related to D. It sounds like your project would be closely related to D (create a language similar to D that uses .NET, right?). It might even be based on the DMD's front-end code. By the way, the idea of a D.NET has already been discussed in a dsource topic: http://www.dsource.org/forums/viewtopic.php?t=140 (It was more a conceptual discussion than an actual request to start a project.) jcc7
Nov 26 2005
next sibling parent reply John Reimer <terminal.node gmail.com> writes:
J C Calvarese wrote:
 In article <d1mho11g54e2iv8i2fovn5rb1as7eoel6s 4ax.com>, Chris says...
 
On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
wrote:

It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
I think to be eligible for dsource a project needs to be open source and either using D or related to D. It sounds like your project would be closely related to D (create a language similar to D that uses .NET, right?). It might even be based on the DMD's front-end code. By the way, the idea of a D.NET has already been discussed in a dsource topic: http://www.dsource.org/forums/viewtopic.php?t=140 (It was more a conceptual discussion than an actual request to start a project.) jcc7
Heh... and I was one of the ones originally against it. But things change... I'm sure D on .NET is the idea. I don't think the idea is to create a language similar to D. The language is still D. It just needs to interface with .NET. -JJR
Nov 26 2005
parent reply Chris <ctlajoie yahoo.com> writes:
On Sat, 26 Nov 2005 16:13:26 -0800, John Reimer
<terminal.node gmail.com> wrote:

 I think to be eligible for dsource a project needs to be open source and either
 using D or related to D. It sounds like your project would be closely related
to
 D (create a language similar to D that uses .NET, right?). It might even be
 based on the DMD's front-end code.
 
 By the way, the idea of a D.NET has already been discussed in a dsource topic:
 http://www.dsource.org/forums/viewtopic.php?t=140
 
 (It was more a conceptual discussion than an actual request to start a
project.)
 
 jcc7
Heh... and I was one of the ones originally against it. But things change... I'm sure D on .NET is the idea. I don't think the idea is to create a language similar to D. The language is still D. It just needs to interface with .NET. -JJR
I am not sure how we could use namespaces (.net) *and* modules (D). We could either add a namespace directive to D.NET, or we could the 'module' keyword indicate the namespace. either way, it is a deviation from the D spec. Chris
Nov 26 2005
parent J C Calvarese <technocrat7 gmail.com> writes:
In article <2i7io1p2amsbu0a0j6mpnc6j358ebmtep3 4ax.com>, Chris says...
On Sat, 26 Nov 2005 16:13:26 -0800, John Reimer
<terminal.node gmail.com> wrote:

 I think to be eligible for dsource a project needs to be open source and either
 using D or related to D. It sounds like your project would be closely related
to
 D (create a language similar to D that uses .NET, right?). It might even be
 based on the DMD's front-end code.
 
 By the way, the idea of a D.NET has already been discussed in a dsource topic:
 http://www.dsource.org/forums/viewtopic.php?t=140
 
 (It was more a conceptual discussion than an actual request to start a
project.)
 
 jcc7
Heh... and I was one of the ones originally against it. But things change... I'm sure D on .NET is the idea. I don't think the idea is to create a language similar to D. The language is still D. It just needs to interface with .NET. -JJR
I am not sure how we could use namespaces (.net) *and* modules (D). We could either add a namespace directive to D.NET, or we could the 'module' keyword indicate the namespace. either way, it is a deviation from the D spec. Chris
jcc7
Nov 26 2005
prev sibling parent Chris <ctlajoie yahoo.com> writes:
On Sun, 27 Nov 2005 00:04:55 +0000 (UTC), J C Calvarese
<technocrat7 gmail.com> wrote:

In article <d1mho11g54e2iv8i2fovn5rb1as7eoel6s 4ax.com>, Chris says...
On Sat, 26 Nov 2005 10:35:26 -0000, "John C" <johnch_atms hotmail.com>
wrote:
It would seem there are several people in this group doing the same thing - 
would it not make sense to join forces to get a fully functional D.NET 
compiler out the door? 
Who else is currently working on one? I recall one or two who said they would help if there was an open source project, but I don't remember anyone saying they were already working on one (except Deja Augustine over a year ago. his compiler wasn't open source anyway). Mine will be open source, perhaps on sourceforge (I believe dsource is for D projects only). If anyone knows where I should host it I'm open to suggestions. I prefer to use svn instead of cvs. Chris
I think to be eligible for dsource a project needs to be open source and either using D or related to D. It sounds like your project would be closely related to D (create a language similar to D that uses .NET, right?). It might even be based on the DMD's front-end code. By the way, the idea of a D.NET has already been discussed in a dsource topic: http://www.dsource.org/forums/viewtopic.php?t=140 (It was more a conceptual discussion than an actual request to start a project.) jcc7
I decided I would not use the DMD front-end as a basis for my compiler. I would certainly use it as a reference, but my project will Mac. thanks for the link. Chris
Nov 26 2005
prev sibling parent "Walter Bright" <newshound digitalmars.com> writes:
"Chris" <ctlajoie yahoo.com> wrote in message
news:h83go15mparb57e1f5d7uroprpo13seb0f 4ax.com...
 I am however very interested in compiling D (there would have to be
 some slight deviations in the syntax) directly to MSIL. In fact I'm
 reading up on compiler design and experimenting with a toy language I
 created that compiles to MSIL. Soon hopefully I will understand enough
 to begin writing one for D.
The book you want is: "Compiling for the .NET Common Language Runtime (CLR)" by John Gough
Dec 01 2005
prev sibling next sibling parent Georg Wrede <georg.wrede nospam.org> writes:
John C wrote:
 At least a couple of people were interested in using .NET from D. The 
 attached example shows one way of doing it, without hosting the CLR.
 
 Here's a taster:
 
     _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
     ICollection collection = com_cast!(ICollection)(arrayList);
     int index;
     collection.add(VARIANT(12345), index);
 
     VARIANT v;
     collection.get_Item(index, v);
     writefln(v.lVal);
 
 Note that the attached files include only the bare minimum to get the
 example to run. I've not defined all the CLR types and some are
 merely placeholders. I've only tested this with .NET 2.0 (but it
 should work with 1.0/1.1).
Excellent! Just read through the zip, already now it has enormous value. I've been putting off certain Windows projects, but this is the straw that broke my procrastination! Something else I'll use this for: flaunting around with this impresses a lot of Suits and Pointy-haireds. Yet more fuel to D-evangelizing! (I know, i know, but it's like when people buy digital cameras, there just absolutely has to be the maximum pixels you can buy -- and then everybody turns the knob to 1024x768 anyway. What a joke.)
 Enjoy. 
You bet!
Nov 26 2005
prev sibling next sibling parent reply John Reimer <terminal.node gmail.com> writes:
John C wrote:
 At least a couple of people were interested in using .NET from D. The 
 attached example shows one way of doing it, without hosting the CLR.
 
 Here's a taster:
 
     _ArrayList arrayList = ArrayList.createObject!(_ArrayList);
     ICollection collection = com_cast!(ICollection)(arrayList);
     int index;
     collection.add(VARIANT(12345), index);
 
     VARIANT v;
     collection.get_Item(index, v);
     writefln(v.lVal);
 
 Note that the attached files include only the bare minimum to get the 
 example to run. I've not defined all the CLR types and some are merely 
 placeholders. I've only tested this with .NET 2.0 (but it should work with 
 1.0/1.1).
 
 Enjoy. 
 
 
I'm curious. I'm not a huge fan of .NET technology (or Microsoft in general), but I do see it's usefulness in some applications. For example, if having access to .NET allows me to program with D on mobile devices with the .NET compact framework installed, then I'm all for it. I'd love to have easy access to programming my Windows Mobile 5.0 device, especially in D. So is this an option? Will this allow me to develop on my mobile device at some point? -JJR
Nov 26 2005
parent reply "John C" <johnch_atms hotmail.com> writes:
"John Reimer" <terminal.node gmail.com> wrote in message 
news:dmaa02$2pdg$1 digitaldaemon.com...
 I'm curious. I'm not a huge fan of .NET technology (or Microsoft in 
 general), but I do see it's usefulness in some applications.  For example, 
 if having access to .NET allows me to program with D on mobile devices 
 with the .NET compact framework installed, then I'm all for it. I'd love 
 to have easy access to programming my Windows Mobile 5.0 device, 
 especially in D.

 So is this an option? Will this allow me to develop on my mobile device at 
 some point?
Only if D outputs executables that are compatible with Windows Mobile - that is, if Win32 PEs run on the Mobile platform, which if I recall they don't.
Nov 26 2005
parent reply John Reimer <terminal.node gmail.com> writes:
John C wrote:
 "John Reimer" <terminal.node gmail.com> wrote in message 
 news:dmaa02$2pdg$1 digitaldaemon.com...
 
I'm curious. I'm not a huge fan of .NET technology (or Microsoft in 
general), but I do see it's usefulness in some applications.  For example, 
if having access to .NET allows me to program with D on mobile devices 
with the .NET compact framework installed, then I'm all for it. I'd love 
to have easy access to programming my Windows Mobile 5.0 device, 
especially in D.

So is this an option? Will this allow me to develop on my mobile device at 
some point?
Only if D outputs executables that are compatible with Windows Mobile - that is, if Win32 PEs run on the Mobile platform, which if I recall they don't.
I was under the impression that if you made a D .NET compiler, it would compile to the VM and, thus, run on any .NET based device, much like Java and its VM. This isn't so? -JJR
Nov 26 2005
parent reply "John C" <johnch_atms hotmail.com> writes:
"John Reimer" <terminal.node gmail.com> wrote in message 
news:dmand7$u49$1 digitaldaemon.com...
 John C wrote:
 "John Reimer" <terminal.node gmail.com> wrote in message 
 news:dmaa02$2pdg$1 digitaldaemon.com...

I'm curious. I'm not a huge fan of .NET technology (or Microsoft in 
general), but I do see it's usefulness in some applications.  For 
example, if having access to .NET allows me to program with D on mobile 
devices with the .NET compact framework installed, then I'm all for it. 
I'd love to have easy access to programming my Windows Mobile 5.0 device, 
especially in D.

So is this an option? Will this allow me to develop on my mobile device 
at some point?
Only if D outputs executables that are compatible with Windows Mobile - that is, if Win32 PEs run on the Mobile platform, which if I recall they don't.
I was under the impression that if you made a D .NET compiler, it would compile to the VM and, thus, run on any .NET based device, much like Java and its VM. This isn't so?
Yes, I believe so, but we're talking about two different but related things on this thread, and they appear to have become somewhat muddied. One is using the .NET framework from native D. The other is (the reverse) a .NET compiler for D. Your question was in response to my example using .NET from D natively, which determined my answer.
 -JJR 
Nov 26 2005
parent John Reimer <terminal.node gmail.com> writes:
John C wrote:
 "John Reimer" <terminal.node gmail.com> wrote in message 
 news:dmand7$u49$1 digitaldaemon.com...
 
John C wrote:

"John Reimer" <terminal.node gmail.com> wrote in message 
news:dmaa02$2pdg$1 digitaldaemon.com...


I'm curious. I'm not a huge fan of .NET technology (or Microsoft in 
general), but I do see it's usefulness in some applications.  For 
example, if having access to .NET allows me to program with D on mobile 
devices with the .NET compact framework installed, then I'm all for it. 
I'd love to have easy access to programming my Windows Mobile 5.0 device, 
especially in D.

So is this an option? Will this allow me to develop on my mobile device 
at some point?
Only if D outputs executables that are compatible with Windows Mobile - that is, if Win32 PEs run on the Mobile platform, which if I recall they don't.
I was under the impression that if you made a D .NET compiler, it would compile to the VM and, thus, run on any .NET based device, much like Java and its VM. This isn't so?
Yes, I believe so, but we're talking about two different but related things on this thread, and they appear to have become somewhat muddied. One is using the .NET framework from native D. The other is (the reverse) a .NET compiler for D. Your question was in response to my example using .NET from D natively, which determined my answer.
-JJR 
Oops! My apologies. I didn't notice. -JJR
Nov 26 2005
prev sibling parent reply "Lionello Lunesu" <lio remove.lunesu.com> writes:
Great stuff! If only the syntax could be streamlined a little...

L. 
Nov 28 2005
parent "John C" <johnch_atms hotmail.com> writes:
"Lionello Lunesu" <lio remove.lunesu.com> wrote in message 
news:dmef4r$1no6$1 digitaldaemon.com...
 Great stuff! If only the syntax could be streamlined a little...

 L.
That's COM for you. In fact, as far as COM goes, that's pretty streamlined, since some functions like QueryInterface and CoCreateInstance are hidden from you in the templates. You could also write wrapper classes so that it has a D interface: class ArrayList { private: _ArrayList clrArrayList_; ICollection clrCollection_; IList clrList_; public: this() { clrArrayList_ = cirrus.c.windows.clr.ArrayList.createObject!(_ArrayList); clrCollection_ = com_cast!(ICollection)(arrayList_); clrList_ = com_cast!(IList)(arrayList_); } ~this() { clrArrayList_.Release(); clrCollection_.Release(); clrList_.Release(); } int add(VARIANT item) { int index; clrList_.Add(item, index); return index; } int indexOf(VARIANT item) { int result; clrList_.IndexOf(item, result); return result; } int count() { int result; clrCollection_.Count(result); return result; } VARIANT opIndex(int index) { VARIANT result; clrList_.get_Item(index, result); return result; } void opIndexAssign(VARIANT item, int index) { clrList_.put_Item(index, item); } int opApply(int delegate(inout VARIANT) d) { int r; for (int i = 0; i < count; i++) { VARIANT var; clrList_.get_Item(i, var); if ((r = d(var)) != 0) break; } return r; } } ArrayList list = new ArrayList; list.add(VARIANT(12345)); list.add(VARIANT(67890)); foreach (VARIANT item; list) { printf("index %d = %d\n", list.indexOf(item), item.lVal); } That's a little better, and could be improved upon further by replacing VARIANT with a some fancy Object boxing/unboxing.
Nov 28 2005