www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2337] New: Can't set .length property in CTF.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2337

           Summary: Can't set .length property in CTF.
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: aziz.kerim gmail.com


The page for functions says that some "properties can be executed at compile
time", and it lists .length as one of those properties. Unfortunately it can
only be accessed by reading it, but assigning a value to it is not possible.

For example:

char[] ctf()
{
  // Create a table:
  char[][] table = [];
  // table.length = 250; // No simple enlargement.
  // Use ugly workaround:
  for (uint i; i < 250; i++)
    table ~= [];

  char[] code = "";
  // Create code from table.
  return code;
}

pragma(msg, ctf());

I think this shouldn't be too difficult to implement.


-- 
Sep 05 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2337


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



This works in dmd1.068 (and dmd2.053).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2011