December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | Tom S wrote: >> auto class StackObj; >> class HeapObj; >> >> StackObj obj0; // Stack-allocated, default-value initialized >> StackObj obj1 = new StackObj(); // Stack-allocated >> HeapObj obj2 = new HeapObj(); // Heap-allocated > > Sometimes I'd like to have a class object defined on the stack, sometimes on the heap (without RAII), would I have then to make 2 classes ? Yes, this is true, I actually didn't think about that very much. In the C# scheme the allocation information is a part of the type itself and cannot be decided during instantiation. This is rather limiting, and can already be done in D with structs. I guess that we really want to allow deciding between allocation models during the instantiation phase, as is done in C++. This is kind of a difficult issue for me since it's very useful feature but adds a significant amount of complexity to the language. And I fear that it necessarily leads to other changes, like 'new' returning a pointer as suggested by others in another thread. I already have nightmares about that! I guess a *really* nice syntax would do the trick, something where the locality of the stack-allocated object would be painfully obvious. C#'s 'using' pattern maybe? using (Object obj = Object()) { // ... work with obj } // obj doesn't exist anymore > Is the D heap allocation syntax already 'frozen' ? It's probably going to make into DMD 0.142 as such and then get modified in a a major, and especially breaking, way in a later version :) -- Niko Korhonen SW Developer |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Niko Korhonen | Niko Korhonen wrote: > I guess that we really want to allow deciding between allocation models during the instantiation phase, as is done in C++. This is kind of a difficult issue for me since it's very useful feature but adds a significant amount of complexity to the language. And I fear that it necessarily leads to other changes, like 'new' returning a pointer as suggested by others in another thread. I already have nightmares about that! What complexity ? We already have it. It's all about the syntactic sugar. > I guess a *really* nice syntax would do the trick, something where the locality of the stack-allocated object would be painfully obvious. C#'s 'using' pattern maybe? > > using (Object obj = Object()) > { > // ... work with obj > } // obj doesn't exist anymore :o I don't like it... Simple things should be simple, remember that. With the proposed D syntax, it's actually pretty obvious... When you use 'new', you get the memory from the heap. When not using it, you get it from the stack. >> Is the D heap allocation syntax already 'frozen' ? > > > It's probably going to make into DMD 0.142 as such and then get modified in a a major, and especially breaking, way in a later version :) lol -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O !M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y ------END GEEK CODE BLOCK------ Tomasz Stachowiak /+ a.k.a. h3r3tic +/ |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | "Anders F Björklund" <afb@algonet.se> wrote in message news:dnojo2$caq$1@digitaldaemon.com... > Dave wrote: > >> What D has done in four years is remarkable when you consider how much was done by one person mostly on free time. C++ had a lot of help from what was then probably the premier CS research organization in the world, and Java had a large and rapidly growing tech. giant behind it. > > I think it could have gotten even further in the "bazaar", but also that the D design and implementation is more coherent as it is now... > > But if Walter hadn't opened up the implementation (i.e. GPL), then I for one wouldn't be here. Mostly since there would not *be* a gdcmac ? > Oh yea - those are things that are so cool about the 'D model' - coherence *and* sharing. Many good things about the language have some about from GDC, ability to run it on a Mac, new library submissions, implementation ideas, etc. One of the things that trully frightened me a while back was the widespread talk of "forking" language development, but I'm certainly not opposed to the free flow of ideas that the 'bazaar' brings - it has been huge in D's favor. Ben Hinkle for example, did the right thing IMHO, he took his ideas and started a new language instead of forking D (I'm not implying that Ben even considered forking D, but no matter what his intentions, he did it the right way. My hat is off to him and anyone else willing to make a commitment like that, that's for sure.). >> And there's no turning back from the big v1.0 release, being that "1.0" >> seems to carry so much weight with people regarding what >> decisions are made for a progamming language from that point on. > > Seems like most software these days go through the stages "beta", "1.0" (a.k.a. Public Beta) and then end up being somewhat final in 1.1 or so. > > Then again, some - like Google - make it a sport to just stay in Beta... > >> That said, I'm often wrong in such matters otherwise I wouldn't be here, but in Bermuda or somewhere warm sipping a beer on the beach. > > Well, this is the internet... > Who says you couldn't be, and still read digitalmars.D.announce ? :-) > > --anders |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | Dave wrote:
> Ben Hinkle for example, did the right thing IMHO, he took his ideas and started a new language instead of forking D (I'm not implying that Ben even considered forking D, but no matter what his intentions, he did it the right way. My hat is off to him and anyone else willing to make a commitment like that, that's for sure.).
>
He did? Where, when, how, what? I didn't know he made a new language? Where did you read about that?
I was certainly around when people were talking about forking, but I had no idea Ben went and made a new language?
-JJR
|
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Niko Korhonen | "Niko Korhonen" <niktheblak@hotmail.com> wrote in message news:dnpd6a$174q$1@digitaldaemon.com... > <snip regarding stack allocation syntax> At the risk of muddling things more, the proposed new sytax (last I saw) was: MyClass mc = new MyClass; // heap MyClass mc2 = MyClass; // RAII (stack or heap, depending on implementor choice (i.e.: GC and machine architecture)) auto MyClass mc3 = new MyClass; // heap and RAII, this syntax will be deprecated but allowed for backward compatibility for a while. auto MyClass mc4 = MyClass; // RAII, this syntax will be deprecated but allowed for backward compatibility for a while. auto mc5 = new MyClass; // heap auto mc6 = MyClass; // RAII (stack or heap, depending on implementor choice (i.e.: GC and machine architecture)) The reasoning is that if you need RAII anyway (destructor fires when it goes out of the current scope) it will be allocated in whichever way the implementor sees fit. From this perspective it is simply just "fast allocated" and the implementation details are left up to the compiler developers, but the compiler still has to do the same "escaping reference" checks it does now for auto. The other important consideration here is that perhaps the D GC can quit checking for a finalizer for every heap allocated class during every GC sweep including that class reference, making the GC much faster too (This would be because, if the class is RAII and those are always stack allocated by implementors choice, then the GC does not have to be built to do the RAII; it has to do that now because RAII is currently heap allocated). > > It's probably going to make into DMD 0.142 as such and then get modified in a a major, and especially breaking, way in a later version :) > Maybe I'm misunderstanding you but that sounds pretty definitive; where are you getting this information? Walter made no such commitments that I've ever seen for v0.142. > > -- > Niko Korhonen > SW Developer |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | "John Reimer" <terminal.node@gmail.com> wrote in message news:dnpmqj$1ggl$1@digitaldaemon.com... > Dave wrote: > >> Ben Hinkle for example, did the right thing IMHO, he took his ideas and started a new language instead of forking D (I'm not implying that Ben even considered forking D, but no matter what his intentions, he did it the right way. My hat is off to him and anyone else willing to make a commitment like that, that's for sure.). >> > > He did? Where, when, how, what? I didn't know he made a new language? Where did you read about that? > More info. is available on his web site. AFAICT, it isn't a direct 'competitor' to D or C++; more of the "C extended" idea, but it does seem to borrow some ideas from D. > I was certainly around when people were talking about forking, but I had no idea Ben went and made a new language? > > -JJR |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | In article <dnpmqj$1ggl$1@digitaldaemon.com>, John Reimer says... > >Dave wrote: > >> Ben Hinkle for example, did the right thing IMHO, he took his ideas and started a new language instead of forking D (I'm not implying that Ben even considered forking D, but no matter what his intentions, he did it the right way. My hat is off to him and anyone else willing to make a commitment like that, that's for sure.). >> > >He did? Where, when, how, what? I didn't know he made a new language? > Where did you read about that? It's called "Cx". I don't know that it's based on the DMD front end at all. See http://home.comcast.net/~benhinkle/cx.html jcc7 |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | "John Reimer" <terminal.node@gmail.com> wrote in message news:dnpmqj$1ggl$1@digitaldaemon.com... > Dave wrote: > >> Ben Hinkle for example, did the right thing IMHO, he took his ideas and started a new language instead of forking D (I'm not implying that Ben even considered forking D, but no matter what his intentions, he did it the right way. My hat is off to him and anyone else willing to make a commitment like that, that's for sure.). >> > > He did? Where, when, how, what? I didn't know he made a new language? Where did you read about that? > > I was certainly around when people were talking about forking, but I had no idea Ben went and made a new language? > > -JJR I'm still goofing around with it so it'll take a while to get anything worth a damn. It's hacking the tinycc compiler to do D-like things with some twists. I'm having fun which currently is my only goal. :-) I hadn't considered forking D - that someone feels rude to me since D is so new. I'm still very much paying attention to D stuff though. I'm not posting as much but I try to keep up with things. |
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | Kris scriva:
> Well ~ the comment was made somewhat tongue-in-cheek :-)
>
> Yet, it feels like I've been using an "official" release for ages <g>
Hehe, ok, I understand :) I'm just afraid of D being thought of as the AOL version number jumper of the programming languages.
Anders F Björklund escreva:
> clayasaurus wrote:
> I think it should follow the lead of another celestial-body-named company, and rename the next release "DMD 142". That's sure to leave
> Java in the mud, as they've only gotten to 5 in all this time... :-P
>
> Seriously, it's not so much about numbers as about alpha/beta/release ?
>
> --anders
The problem is, maybe it is just me, that version 2.0 detonates it as the /second/ release.
If we arn't going to care about version numbers, here are a few more suggestions...
D 360, because we all know 360 is equated with fun!
D 2014, who cares if it was released in 2005-6, it is just that much ahead of its time
D 9.0 Optimized Edition, with full programmer protection
D 3.0, followed by 3.1, followed by 3.14, etc.
D XP, Ultimate Edition, Starter Edition, Enterprise Edition, collect them all
D Cruise Control With A Vengance
Pick your poison :-P
|
December 14, 2005 Re: A safer/better C++? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote:
>
> I'm still goofing around with it so it'll take a while to get anything worth a damn. It's hacking the tinycc compiler to do D-like things with some twists. I'm having fun which currently is my only goal. :-) I hadn't considered forking D - that someone feels rude to me since D is so new.
> I'm still very much paying attention to D stuff though. I'm not posting as much but I try to keep up with things.
>
>
>
A thanks for explaining, Ben! The context just sounded a little too sinister for you! :D
I did actually manage to find Cx on your website after it was mentioned here.
-JJR
|
Copyright © 1999-2021 by the D Language Foundation