aboutsummaryrefslogtreecommitdiff
path: root/docs/notes/pointer_arithmetic.txt
blob: ef7fe1568a4173eb0e28726b24c735a41b15ef12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

how to make pointer arithmetic safe?
------------------------------------

Alternative 1: use arrays with length constraints instead

    byte#[strlen(value)]^ p;
    
    if (p^#[0] == 0) return;
    p = @p^#[1];
    

Alternative 2: use special pointer types, and none values

    typedef cchar = enum(1..255)?;

    cchar>^ p;
    if (not p:next()) return;