1 Date: Tue, 6 Feb 2001 20:27:37 -0600 (CST) 2 From: Chris Lattner <sabre (a] nondot.org> 3 To: Vikram S. Adve <vadve (a] cs.uiuc.edu> 4 Subject: Type notation debate... 5 6 This is the way that I am currently planning on implementing types: 7 8 Primitive Types: 9 type ::= void|bool|sbyte|ubyte|short|ushort|int|uint|long|ulong 10 11 Method: 12 typelist ::= typelisth | /*empty*/ 13 typelisth ::= type | typelisth ',' type 14 type ::= type (typelist) 15 16 Arrays (without and with size): 17 type ::= '[' type ']' | '[' INT ',' type ']' 18 19 Pointer: 20 type ::= type '*' 21 22 Structure: 23 type ::= '{' typelist '}' 24 25 Packed: 26 type ::= '<' INT ',' type '>' 27 28 Simple examples: 29 30 [[ %4, int ]] - array of (array of 4 (int)) 31 [ { int, int } ] - Array of structure 32 [ < %4, int > ] - Array of 128 bit SIMD packets 33 int (int, [[int, %4]]) - Method taking a 2d array and int, returning int 34 35 36 Okay before you comment, please look at: 37 38 http://www.research.att.com/~bs/devXinterview.html 39 40 Search for "In another interview, you defined the C declarator syntax as 41 an experiment that failed. However, this syntactic construct has been 42 around for 27 years and perhaps more; why do you consider it problematic 43 (except for its cumbersome syntax)?" and read that response for me. :) 44 45 Now with this syntax, his example would be represented as: 46 47 [ %10, bool (int, int) * ] * 48 49 vs 50 51 bool (*(*)[10])(int, int) 52 53 in C. 54 55 Basically, my argument for this type construction system is that it is 56 VERY simple to use and understand (although it IS different than C, it is 57 very simple and straightforward, which C is NOT). In fact, I would assert 58 that most programmers TODAY do not understand pointers to member 59 functions, and have to look up an example when they have to write them. 60 61 In my opinion, it is critically important to have clear and concise type 62 specifications, because types are going to be all over the programs. 63 64 Let me know your thoughts on this. :) 65 66 -Chris 67 68