Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One other neat thing about discriminated records is that you're not limited to just a single field with a variable size, you can also write something like this:

    type My_Record (A, B : My_Integer) is record
       X : My_Array (1 .. A);
       Y : My_Array (1 .. B);
    end record;
A record that's created from this will have those arrays tightly packed rather than leaving space at the end of the first one like you might expect (this might be compiler dependant, but it's definitely how GCC does it). Also note that these values can be set at runtime, so this isn't just a generic in disguise (although in Ada you can also instantiate generics at runtime).


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: