FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why use dollar ?

 
Post new topic   Reply to topic     Forum Index -> Build
View previous topic :: View next topic  
Author Message
afb



Joined: 26 Jan 2005
Posts: 137
Location: Sweden

PostPosted: Mon Apr 25, 2005 1:44 am    Post subject: Why use dollar ? Reply with quote

Since $ is an experimental feature, should it really be in Build ?

Quote:
expression expected, not 'TOK36'


(It was added in DMD 0.116, and GDC is currently at 0.113 frontend)

Here is a shell script that will change files back to using "length":

Code:
find . -name '*.d' | xargs -n 1 perl -pe 's/\$/length/g' -i.dollar


I'm not saying that the naked length should be used (just did that a
workaround), but the more stable construction is "ArrayName.length" ?
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Mon Apr 25, 2005 3:47 am    Post subject: Re: Why use dollar ? Reply with quote

afb wrote:
Since $ is an experimental feature, should it really be in Build ?

I guess that means I'm helping Walter with his experiment. Wink

afb wrote:
Quote:
expression expected, not 'TOK36'


(It was added in DMD 0.116, and GDC is currently at 0.113 frontend)

Here is a shell script that will change files back to using "length":

Code:
find . -name '*.d' | xargs -n 1 perl -pe 's/\$/length/g' -i.dollar


I'm not saying that the naked length should be used (just did that a
workaround), but the more stable construction is "ArrayName.length" ?

I'm really sorry that GDC is so far behind DMD, because I want to use the latest D functionality. If I have to either stick with the lowest common set or have multiple versions, it removes my enthusiasm to work on the project.

I don't know what to do with this one.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
afb



Joined: 26 Jan 2005
Posts: 137
Location: Sweden

PostPosted: Mon Apr 25, 2005 7:42 am    Post subject: Reply with quote

It's not a big deal, just that if you want it to compile
"out of the box" on GDC <= 0.11, you need to use
the long form instead of the short form ($)...

With GDC 0.12 or so, David should be synched to
DMD 0.121 so then it should be supported there too.
For a while... (in case Walter pulls it out again ?)

I can wrap it into a patch, and then GDC users
can just apply that before compiling ? Whichever
is easiest, the patch is generated as per above...

(gendiff trunk .dollar)
Back to top
View user's profile Send private message
afb



Joined: 26 Jan 2005
Posts: 137
Location: Sweden

PostPosted: Mon Apr 25, 2005 7:55 am    Post subject: Reply with quote

build-2.0-dollar.patch:
Code:

--- trunk/Source/build.d.dollar   Mon Apr 25 09:34:02 2005
+++ trunk/Source/build.d   Mon Apr 25 09:35:50 2005
@@ -723,14 +728,14 @@
         if (util.str.Begins(lLine, "rule=") )
         {
             lRules.length = lRules.length + 1;
-            lRules[$-1].Name = lLine[5 .. $];
+            lRules[length-1].Name = lLine[5 .. length];
         }
         else if (util.str.Begins(lLine, "in=") && (lRules.length > 0))
-            lRules[$-1].Input = lLine[3..$];
+            lRules[length-1].Input = lLine[3..length];
         else if (util.str.Begins(lLine, "out=") && (lRules.length > 0) )
-            lRules[$-1].Output = lLine[4..$];
+            lRules[length-1].Output = lLine[4..length];
         else if (util.str.Begins(lLine, "tool=") && (lRules.length > 0) )
-            lRules[$-1].Tool = lLine[5..$];
+            lRules[length-1].Tool = lLine[5..length];
     }
 
     if (vVerbose)
@@ -1157,9 +1162,9 @@
             if (vAllObjects || lFileDir == "" || lFileDir == lTargetDir) {
                 if (lFileName.length > 1 + kSrcExtention.length)
                 {
-                    if (lFileName[$-kSrcExtention.length .. $] == kSrcExtention)
+                    if (lFileName[length-kSrcExtention.length .. length] == kSrcExtention)
                     {
-                        lFileName = lFileName[0..$-kSrcExtention.length] ~ kObjExtention;
+                        lFileName = lFileName[0..length-kSrcExtention.length] ~ kObjExtention;
                     }
                 }
 
@@ -1264,8 +1269,8 @@
 {
     if (pPath.length > 0) {
         vExternals.length = vExternals.length + 1;
-        vExternals[$-1].FilePath = pPath;
-        vExternals[$-1].ToolOpts = pOpts;
+        vExternals[length-1].FilePath = pPath;
+        vExternals[length-1].ToolOpts = pOpts;
         if (vVerbose) {
             writef("Added external file to be built: ?s", pPath);
             foreach( char[] lOpt; pOpts)
@@ -2039,8 +2044,8 @@
                     if (util.str.IsLike(pArg,  cast(dchar[])"-RDF*"))
                     {
                         if (vVerbose)
-                            writefln("RDF was ?s now ?s", vRDFName, pArg[4..$]);
-                        vRDFName = pArg[4..$].dup;
+                            writefln("RDF was ?s now ?s", vRDFName, pArg[4..length]);
+                        vRDFName = pArg[4..length].dup;
                         vBuildArgs ~= pArg;
                         break;
 
@@ -2049,7 +2054,7 @@
                     if (util.str.IsLike(pArg,  std.utf.toUTF32(vImportPathSwitch ~ "*")))
                     {
                         char [] lRoot;
-                        lRoot = AddRoot(pArg[2..$]);
+                        lRoot = AddRoot(pArg[2..length]);
                         if (lRoot.length > 0){
                             version(Posix)
                                 vDefaultCompArgs ~= vImportPathSwitch ~ "\"" ~ lRoot ~ "\"";
@@ -2069,8 +2074,8 @@
                     {
                         char[] lRoot;
 
-                        vObjWritePath = pArg[vObjWritePathSwitch.length .. $];
-                        if (vObjWritePath.length > 0 && vObjWritePath[$-1..$] != std.path.sep)
+                        vObjWritePath = pArg[vObjWritePathSwitch.length .. length];
+                        if (vObjWritePath.length > 0 && vObjWritePath[length-1..length] != std.path.sep)
                             vObjWritePath ~= std.path.sep;
 
                         lRoot = AddRoot(vObjWritePath);
@@ -2089,7 +2094,7 @@
                     if (util.str.IsLike(pArg,  cast(dchar[])"-X*"))
                     {
                         // Modules to ignore (eg. -Xmylib)
-                        vModulesToIgnore ~= pArg[2..$];
+                        vModulesToIgnore ~= pArg[2..length];
                         vBuildArgs ~= pArg;
                         break;
                     }
@@ -2097,7 +2102,7 @@
                     if (util.str.IsLike(pArg,  cast(dchar[])"-M*"))
                     {
                         // Modules to notice (eg. -Mphobos)
-                        vModulesToNotice ~= pArg[2..$];
+                        vModulesToNotice ~= pArg[2..length];
                         vBuildArgs ~= pArg;
                         break;
                     }
@@ -2105,7 +2110,7 @@
                     if (util.str.IsLike(pArg,  cast(dchar[])"-T*"))
                     {
                         // Target name (eg. -Ttestapp)
-                        vCommandTargetName = pArg[2..$];
+                        vCommandTargetName = pArg[2..length];
                         vBuildArgs ~= pArg;
                         break;
                     }
@@ -2115,7 +2120,7 @@
                     if (util.str.IsLike(pArg,  (vOutFileSwitch ~ "*")))
                     {
                         // Target name (eg. -oftestapp)
-                        vCommandTargetName = pArg[vOutFileSwitch.length .. $];
+                        vCommandTargetName = pArg[vOutFileSwitch.length .. length];
                         vBuildArgs ~= pArg;
                         break;
                     }
--- trunk/Source/source.d.dollar   Mon Apr 25 09:30:56 2005
+++ trunk/Source/source.d   Mon Apr 25 09:34:57 2005
@@ -776,9 +776,9 @@
                     while ((lCurrentToken = GetNextToken(pFileText,pPos)) == ",")
                     {
                         lExternOpts.length = lExternOpts.length + 1;
-                        lExternOpts[$-1] = GetNextToken(pFileText,pPos);
-                        if (lExternOpts[$-1] == "\"") {
-                            lExternOpts[$-1] = GetStringLit(pFileText,pPos);
+                        lExternOpts[length-1] = GetNextToken(pFileText,pPos);
+                        if (lExternOpts[length-1] == "\"") {
+                            lExternOpts[length-1] = GetStringLit(pFileText,pPos);
                         }
                     }
 
@@ -1008,7 +1008,7 @@
 
 
     // Remove file extension.
-    if (lModuleName[length-2 .. $] == ".d")
+    if (lModuleName[length-2 .. length] == ".d")
     {
         lModuleName.length = lModuleName.length - 2;
     }
@@ -1017,7 +1017,7 @@
         // Remove the 'Drive' letter if present.
         if (lModuleName.length > 1  &&  lModuleName[1] == ':')
         {
-            lModuleName = lModuleName[2..$];
+            lModuleName = lModuleName[2..length];
         }
     }
     // Replace opsys path separators with dots.
--- trunk/Source/util/BMscanner.d.dollar   Thu Apr 14 16:13:24 2005
+++ trunk/Source/util/BMscanner.d   Mon Apr 25 09:34:57 2005
@@ -86,7 +86,7 @@
     if (pStartPos < 0)
         return -1;
     if (pStartPos > 0)
-        pContainer = pContainer[pStartPos .. $];
+        pContainer = pContainer[pStartPos .. length];
     if (pContainer.length == 0)
         return -1;
     if (pFind.length > pContainer.length)
@@ -96,7 +96,7 @@
     if (pFind.length == 1)
     {
         T pElem = pFind[0];
-        foreach(int i, T lElem; pContainer[pStartPos .. $])
+        foreach(int i, T lElem; pContainer[pStartPos .. length])
         {
             if ( lElem == pElem)
                 return i + pStartPos;
@@ -193,7 +193,7 @@
 
 int BMScanElement(T[] pContainer, T pFind, uint pStartPos=0)
 {
-    foreach(int i, T lElem; pContainer[pStartPos .. $])
+    foreach(int i, T lElem; pContainer[pStartPos .. length])
     {
         if ( lElem == pFind)
             return i + pStartPos;
--- trunk/Source/util/fileex.d.dollar   Thu Apr 14 16:13:24 2005
+++ trunk/Source/util/fileex.d   Mon Apr 25 09:34:57 2005
@@ -85,7 +85,7 @@
     {
         lFileText = cast(char[]) std.file.read(pFileName);
         if ( (lFileText.length == 0) ||
-             (lFileText[$-1] != '\n'))
+             (lFileText[length-1] != '\n'))
              lFileText ~= std.path.linesep;
     }
     else if (pOpt == GetOpt.Exists) {
@@ -199,7 +199,7 @@
     lResult.length = 0;
     lPos = 0;
 
-    while ( (lPos = bmfind(lBuffer[lPos..$], pText)) != -1)
+    while ( (lPos = bmfind(lBuffer[lPos..length], pText)) != -1)
     {
         if (lWordOnly)
         {
@@ -222,7 +222,7 @@
         }
 
         lResult.length = lResult.length + 1;
-        lResult[$-1] = lPos;
+        lResult[length-1] = lPos;
         if (lCounting)
         {
             pMax--;
--- trunk/Source/util/linetoken.d.dollar   Thu Apr 14 16:13:24 2005
+++ trunk/Source/util/linetoken.d   Mon Apr 25 09:34:57 2005
@@ -195,7 +195,7 @@
     if (lTrimSpot != -1)
     {
         // Trim off trailing spaces on last token.
-        lResult[$-1].length = lTrimSpot-1;
+        lResult[length-1].length = lTrimSpot-1;
     }
 
     return lResult;
--- trunk/Source/util/pathex.d.dollar   Thu Apr 14 16:13:24 2005
+++ trunk/Source/util/pathex.d   Mon Apr 25 09:34:57 2005
@@ -81,7 +81,7 @@
 
     lCurDir =  getcwd();
     // Ensure that it ends in a path separator.
-    if (lCurDir[$-std.path.sep.length .. $] != std.path.sep)
+    if (lCurDir[length-std.path.sep.length .. length] != std.path.sep)
         lCurDir ~= std.path.sep;
 
     return lCurDir;
@@ -121,7 +121,7 @@
         }
     }
 
-    if (pFinal && (lPath[$-std.path.sep.length .. $] != std.path.sep) ){
+    if (pFinal && (lPath[length-std.path.sep.length .. length] != std.path.sep) ){
         lPath ~= std.path.sep;
     }
 
@@ -271,7 +271,7 @@
             uint lPos;
             while ( (lPos = bmfind(pName, `\\`)) != -1)
             {
-                pName = pName[0..lPos] ~ pName[lPos+1 .. $];
+                pName = pName[0..lPos] ~ pName[lPos+1 .. length];
             }
         }
         return pName;
@@ -285,7 +285,7 @@
         if (std.string.tolower(lShortName[0.. lCurDir.length]) ==
             std.string.tolower(lCurDir) )
         {
-            lShortName = lShortName[lCurDir.length .. $];
+            lShortName = lShortName[lCurDir.length .. length];
         }
 
         // Remove any double path seps.
@@ -293,7 +293,7 @@
             uint lPos;
             while ( (lPos = bmfind(lShortName, `\\`)) != -1)
             {
-                lShortName = lShortName[0..lPos] ~ lShortName[lPos+1 .. $];
+                lShortName = lShortName[0..lPos] ~ lShortName[lPos+1 .. length];
             }
         }
     }
@@ -301,7 +301,7 @@
     {
         if (lShortName[0.. lCurDir.length] == lCurDir )
         {
-            lShortName = lShortName[lCurDir.length .. $];
+            lShortName = lShortName[lCurDir.length .. length];
         }
     }
 
@@ -323,7 +323,7 @@
         if (lPath.length == 0)
             lPath = std.path.curdir.dup;
 
-        if (lPath[$-std.path.sep.length .. $] != std.path.sep)
+        if (lPath[length-std.path.sep.length .. length] != std.path.sep)
             lPath ~= std.path.sep;
 
         lFullName = lPath ~ pFileName;
--- trunk/Source/util/str.d.dollar   Thu Apr 14 16:13:24 2005
+++ trunk/Source/util/str.d   Mon Apr 25 09:34:57 2005
@@ -740,7 +740,7 @@
                 break;
             lResult = lResult[0..lPos] ~
                       lReplacement ~
-                      lResult[lPos + lToken.length .. $];
+                      lResult[lPos + lToken.length .. length];
         }
     }
 
@@ -749,12 +749,12 @@
     {
         int lPos2;
 
-        lPos2 = bmfind(lResult[lPos+1 .. $], pTrailing);
+        lPos2 = bmfind(lResult[lPos+1 .. length], pTrailing);
         if (lPos2 == -1)
             break;
 
         lResult = lResult[0 .. lPos] ~
-                  lResult[lPos2 + lPos + pLeading.length + pTrailing.length .. $];
+                  lResult[lPos2 + lPos + pLeading.length + pTrailing.length .. length];
     }
 
     return lResult;


BTW; How do you attach text files to this forum ?
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Thu Apr 28, 2005 12:53 am    Post subject: Reply with quote

Since David Friedman released GDC 0.11 tonight (which is apparently synched up to DMD 0.121), the dollar sign issue and many other inconsistencies between the newest DMD and GDC may not be a problem any more.

(I wouldn't want to have to "dumb down" my source to cater to the lowest common denominator either.)
Back to top
View user's profile Send private message AIM Address
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Thu Apr 28, 2005 2:07 am    Post subject: Reply with quote

jcc7 wrote:
Since David Friedman released GDC 0.11 tonight (which is apparently synched up to DMD 0.121), the dollar sign issue and many other inconsistencies between the newest DMD and GDC may not be a problem any more.

(I wouldn't want to have to "dumb down" my source to cater to the lowest common denominator either.)

I spoke with David a few days ago about this. He assured me that GDC will be upgraded to .121 compatability soon, so I've held off releasing the next version of Build until that was done. I haven't removed '$' or __TIMESTAMP__ from my sources.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
afb



Joined: 26 Jan 2005
Posts: 137
Location: Sweden

PostPosted: Thu Apr 28, 2005 7:10 am    Post subject: Reply with quote

GDC 0.11 is updated to D 0.121, so Build now builds...

At least until Walter changes the '$' "feature" again. Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Build All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group