www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Review needed for the wiki - Pascal to D page

reply "Baz" <basile.burg. gmx.com> writes:
"Attack" me on the content of:

   http://wiki.dlang.org/Coming_From/Delphi

This is my user experience about coming from Pascal/Delphi to D.
Dec 04 2014
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Baz:

 "Attack" me on the content of:

   http://wiki.dlang.org/Coming_From/Delphi

 This is my user experience about coming from Pascal/Delphi to D.
Thank you for the work :-) Code Rosetta, etc. => Rosetta Code.
 D has a feature similar to Pascal/delphi source inclusion.
Yes, but in 99.9% cases in D you use the module system.
D has no equivalent feature. The published attribute does not 
exist but instead you have some compile-time reflection<
D has some run-time features, like typeid, and other stuff in object.d.
    public bool opIn_r(char elem){
        import std.algorithm;
        return canFind(str,elem);
    }
There are also ways to do that with an associative array, or with a bit set in amortized O(1) or strict O(1).
 In D, is is used to test the equivalence of two types, at 
 compile-time.
And also to compare bitwise two values, like two class references.
 The D2 way is to use a struct combined with an alias this 
 expression:
There is also the currently not good Phobos "Typedef". Another note worth adding is that built-in D arrays start from index 0 and they have only size_t indexes. There are probably several more things worth adding to that page, but it's a nice start. Bye, bearophile
Dec 04 2014
parent reply "Baz" <basile.burg. gmx.com> writes:
On Thursday, 4 December 2014 at 23:27:05 UTC, bearophile wrote:
 Baz:

 "Attack" me on the content of:

  http://wiki.dlang.org/Coming_From/Delphi

 This is my user experience about coming from Pascal/Delphi to 
 D.
Thank you for the work :-) Code Rosetta, etc. => Rosetta Code.
 D has a feature similar to Pascal/delphi source inclusion.
Yes, but in 99.9% cases in D you use the module system.
D has no equivalent feature. The published attribute does not 
exist but instead you have some compile-time reflection<
D has some run-time features, like typeid, and other stuff in object.d.
   public bool opIn_r(char elem){
       import std.algorithm;
       return canFind(str,elem);
   }
There are also ways to do that with an associative array, or with a bit set in amortized O(1) or strict O(1).
 In D, is is used to test the equivalence of two types, at 
 compile-time.
And also to compare bitwise two values, like two class references.
 The D2 way is to use a struct combined with an alias this 
 expression:
There is also the currently not good Phobos "Typedef". Another note worth adding is that built-in D arrays start from index 0 and they have only size_t indexes. There are probably several more things worth adding to that page, but it's a nice start. Bye, bearophile
Thx, to ketmar too. handled your commments. And that's true that array and slice top index deserve a section, a good oportunity too to introduce opDollar. I was already thinking to add one because the "foreach(i; 0 .. 8)" expression is closed to the Pascal "for ... to ..." loop syntax, with the top index ambiguity in more.
Dec 04 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
Baz:

 I was already thinking to add one because the "foreach(i; 0 .. 
 8)"
Better to write: foreach(immutable i; 0 .. 8) Bye, bearophile
Dec 05 2014
prev sibling next sibling parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Thu, 04 Dec 2014 22:04:39 +0000
Baz via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 "Attack" me on the content of:
=20
    http://wiki.dlang.org/Coming_From/Delphi
typo: type ISome =3D interfaca type TSomething =3D classs(TThing, ISome) also, it's worth noting that Delphi's IFDEF/ENDIF completely ignores everything inbetwee if condition is false, but D `version` and `static if` requires ignored code to be correct D code nevertheless. ah, and thanks for your work! ;-)
Dec 04 2014
prev sibling next sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Fri, Dec 05, 2014 at 03:39:07AM +0200, ketmar via Digitalmars-d wrote:
[...]
 also, it's worth noting that Delphi's IFDEF/ENDIF completely ignores
 everything inbetwee if condition is false, but D `version` and `static
 if` requires ignored code to be correct D code nevertheless.
[...] That's not completely true. All that's required is that the code can be parsed successfully. It can be semantically nonsense and the compiler wouldn't care, for example this will compile, even though it's complete garbage: version(none) { NonExistentType x = nonExistentVar; static assert(0); NoType YesParsingStillContinuesHere()(z = y+w ? 1 : "") if (is(a == b)) // a and b are nonsense symbols in { static assert(0); } body { gar(bage) = hahaha(cast(el)ation); {{{}}{}{{}}} } pragma(no, such, __trait(nonsense)); } T -- Любишь кататься - люби и саночки возить.
Dec 04 2014
prev sibling parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Thu, 4 Dec 2014 18:22:30 -0800
"H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> wrote:

 On Fri, Dec 05, 2014 at 03:39:07AM +0200, ketmar via Digitalmars-d wrote:
 [...]
 also, it's worth noting that Delphi's IFDEF/ENDIF completely ignores
 everything inbetwee if condition is false, but D `version` and `static
 if` requires ignored code to be correct D code nevertheless.
[...] =20 That's not completely true. All that's required is that the code can be parsed successfully. It can be semantically nonsense and the compiler wouldn't care, for example this will compile, even though it's complete garbage:
ah, sure, thanks. it was a bad wording from my side.
Dec 04 2014