Changes between Version 3 and Version 4 of Pointers


Ignore:
Timestamp:
09/15/13 10:05:04 (13 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Pointers

    v3 v4  
    6363A type pointer-to-T1-in-s can be cast to a type pointer-to-T2-in-s according to the usual rules of C (or whatever variation is used in CIVL-C). In other words, usual casting rules apply as long as you don't change the scope.
    6464
    65 == Parameterized typedefs ==
     65== Scope-parameterized types ==
    6666
    6767typedefs can be parameterized by scopes, e.g.
     
    8686<s1,s2,s3> typedef struct ...
    8787}}}
     88
     89Structs can also be parameterized by scopes:
     90
     91{{{
     92<s> struct Node {
     93  int id;
     94  Node<s> *<s> next;
     95}
     96
     97void f() {
     98  $scope s1;
     99  struct Node<s1> u, v;
     100  u.id = 0;
     101  u.next = &v;
     102  v.id = 1;
     103  v.next = NULL;
     104}
     105}}}
     106
     107If you want to combine a typedef and struct definition where both are parameterized, you have to break it up into two steps:
     108
     109{{{
     110<s> struct _Node { … }
     111<s> typedef struct _Node<s> Node;
     112}}}
     113
    88114
    89115== Parameterized procedures ==