Last update October 25, 2007

Feature Request List /
Compile Time Char Type Identification



Strongly recommend the D language to support new feature of “compile time char type identification”

D is a new language it has lot of advantages over C/C++. But it has some obvious disadvantages

  1. It’s main function only accepts char[][] args but wchar[][] and dchar[][] args. As a result if user pass Unicode args to it, it may get a wrong result.
  2. Developer have to write lots of similar functions to handle all char types
For example a developer written a class
 class Foo
 {
	char[][] name;
	void setNamea(char[] name){}
	void setNamew(wchar[] name){}
	void setNamed(dchar[] name){}

}

It is very ugly, and I hate to write this code.

What I wish is only write the simple and natural code like this

 class Foo
 {
	char[][] name;
	void setName(char[] name){}
 }

The char[] can stands for achar/wchar/dchar, and developer can specify the type in the package.ini file. With the ini file the develop can build Asicll, Unicode or UTF-32 versions libraries/applications.

How to approach the goal.

  1. Introduce a new key work achar stands for Asicll chars
  2. Add a ini file to the package. The ini file is optional. If no such a file all “char” in the source file will be treat as wchar, if there is a ini file treat the char as specified type. So all developers in the world can possibly use D language without concern the char type. Unicode is the future.
  3. String in source code now has three suffix. For example “this is achar”c, “this is wchar”w, and “this is dchar”d explicitly indicate they are of achar[], wchar[] and dchar[]. If the user do not add such a suffix the string type may possibly mean the string is achar[], wchar[] or dchar[] depends on the specification of the ini file. If no ini file the string will be treated as wchar[].
  4. Compiler of DMD provide ability to read the ini file and determines the type char and no suffix string.
  5. The format ini file can be a plan text file or XML file. Advise to use XML, it is more extensible.
  6. The ini file can be placed on different folder. Source code use the ini file which is in the same folder.
Risk and possibility.
  1. D language is new, we still has the opportunity to change it.
  2. The migration from old D to the new D will be relatively easer. User can specify the char to stand for certain type to minimize their risk.
  3. D should be more friendly to developer, it is worth doing the change.
What advantages we get?
  1. The D code will be more readable and natural.
  2. Use the same code to generate different versions by only change ini file.
  3. Developer can still use the achar/dchar/dchar explicitly tell the compiler they want to use a special char type. That is to say explicit char type will hide the specification of ini file.
(Originally posted by ForrestFeng? on two DocComments pages on 2007/10/25, see also: NG:digitalmars.D/60848)
FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: October 25, 2007 19:28 (diff))