www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Pointer arithmetic

reply Michal <mlliso wp.pl> writes:
Hi, 
Im new to D language, and Im wondering if there is pointer arithmetic. I think
its very useful thing, sometimes more convenient than [].

Thx for reply.
Oct 15 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Michal wrote:
 Hi, 
 Im new to D language, and Im wondering if there is pointer arithmetic. I think
its very useful thing, sometimes more convenient than [].
Pointer arithmetic works, but (obviously) only when you're actually using pointers. However between class references, real array types and ref (aka inout)/out parameters, raw pointer usage in D programs is typically very low (and is normally discouraged unless there's no other way).
Oct 15 2007
parent reply Kyle Furlong <kylefurlong gmail.com> writes:
Frits van Bommel wrote:
 Michal wrote:
 Hi, Im new to D language, and Im wondering if there is pointer 
 arithmetic. I think its very useful thing, sometimes more convenient 
 than [].
Pointer arithmetic works, but (obviously) only when you're actually using pointers. However between class references, real array types and ref (aka inout)/out parameters, raw pointer usage in D programs is typically very low (and is normally discouraged unless there's no other way).
That being said, D can be used as a better C. (no preprocessor, modules, etc.)
Oct 15 2007
parent reply Alexander Panek <a.panek brainsware.org> writes:
Kyle Furlong wrote:
 That being said, D can be used as a better C. (no preprocessor, modules, 
 etc.)
Definitely! /me puts some emphasis marks around that post
Oct 15 2007
parent reply Kyle Furlong <kylefurlong gmail.com> writes:
Alexander Panek wrote:
 Kyle Furlong wrote:
 That being said, D can be used as a better C. (no preprocessor, 
 modules, etc.)
Definitely! /me puts some emphasis marks around that post
I guess to elaborate on this, since people might find it interesting, for x86 at least, D is a wonderful choice for OS design. I've worked with D in a couple of kernel programming cases, and while you dont have all the bells and whistles of the runtime with the GC and all of that, what you do get is a more sane, manageable C-like language.
Oct 15 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Kyle Furlong" <kylefurlong gmail.com> wrote in message 
news:ff0qrg$16fk$1 digitalmars.com...
 Alexander Panek wrote:
 Kyle Furlong wrote:
 That being said, D can be used as a better C. (no preprocessor, modules, 
 etc.)
Definitely! /me puts some emphasis marks around that post
I guess to elaborate on this, since people might find it interesting, for x86 at least, D is a wonderful choice for OS design. I've worked with D in a couple of kernel programming cases, and while you dont have all the bells and whistles of the runtime with the GC and all of that, what you do get is a more sane, manageable C-like language.
Some friends and I are doing just that right now. We're using GDC and its extended ASM syntax to write an x86-64 exokernel OS. It's certainly a lot nicer to deal with than vanilla C, and with some of the basic runtime elements defined / stubbed out, you don't miss some of the more dynamic features that much. (We haven't gotten dynamic memory or even virtual memory implemented yet ;) )
Oct 15 2007