digitalmars.D - Review needed for the wiki - Pascal to D page
- Baz (3/3) Dec 04 2014 "Attack" me on the content of:
- bearophile (16/30) Dec 04 2014 Thank you for the work :-)
- Baz (7/41) Dec 04 2014 Thx, to ketmar too. handled your commments.
- bearophile (5/7) Dec 05 2014 Better to write:
- ketmar via Digitalmars-d (9/12) Dec 04 2014 typo:
- H. S. Teoh via Digitalmars-d (22/25) Dec 04 2014 [...]
- ketmar via Digitalmars-d (3/14) Dec 04 2014 ah, sure, thanks. it was a bad wording from my side.
"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
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
On Thursday, 4 December 2014 at 23:27:05 UTC, bearophile wrote:Baz: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."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
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
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/Delphitypo: 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
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
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: [...]ah, sure, thanks. it was a bad wording from my side.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:
Dec 04 2014