Better HN
topnewbestaskshowjobs
Log inSign up

psewell

8 karma · joined Jun 1, 2016 (10y ago) · 2 submissions

Submissions

comment 10y ago · link · parent

No. First, understand what the language is for (if nothing, stop here...). Second, make the main design choices (expressiveness of type system, level of control of mutability or lack thereof, etc.). Third, design the type system, with a view to type inference. Fourth, design and define the semantics. Do those last two in a way that will let you test your implementation against these definitions automatically. Fifth, think about sufficiently efficient implementation strategies. Sixth, pick a syntactic style that will be familiar to most of your users. Seventh, design the actual syntax. Eighth, implement it. Ninth, try it out on users and go back to the start. Tenth, rest.

comment 10y ago · link · parent

Indeed. The long version is at [pdf] http://www.cl.cam.ac.uk/~pes20/cerberus/notes30-full.pdf; it has 85 questions supported by concrete code examples and experimental data, e.g. (one of several questions that refine the above):

Q64. After an explicit write of zero to a padding

byte followed by a write to adjacent members of

the structure, does the padding byte hold a

well-defined zero value? (not an unspecified

value)

  #include <stdio.h>

  #include <stddef.h>

  typedef struct { char c; float f; int i; } st;

  int main() {

    // check there is a padding byte between c and f

    size_t offset_padding = offsetof(st,c)+sizeof(char);

    if (offsetof(st,f)>offset_padding) {

        st s; 

        unsigned char *p = 

          ((unsigned char*)(&s)) + offset_padding;

        *p = 0;

        s.c = 'A';

        s.f = 1.0;

        s.i = 42;

        unsigned char c3 = *p; 

        // does c3 hold 0, not an unspecified value?

        printf("c3=0x%x\n",c3);

    }

    return 0;

  }
Some of the questions have clear answers with respect to either the ISO or de facto standards, but many do not - that's the point.