[Nickle] Re: rijndael example

Bart Massey bart at cs.pdx.edu
Mon Jun 9 22:34:25 PDT 2003


Uh, my bad.  It also predates the incompatible Nickle change
that got rid of null pointers forever.  One now needs to use
a disjoint union type in classic functional style.
Here's a complicated example:

    typedef union {
      void null;
      *int addr;
    } intp;
    intp p = intp.null;
    p.addr = reference(3);
    printf("%d\n", *p.addr);
    p.null = <>;
    if (p == intp.null)
      printf("is null\n");

As you have noted, porting C code is thus made much harder.
OTOH, C's null pointers were a huge source of errors and
confusion.  Not sure if this change was a good one, but
there it is...

	Bart

In message <Pine.GSO.4.21.0306092054230.24764-100000 at sirius.cs.pdx.edu> you wrote:
> 
> Bart,
> 
> I decided to play with the rijndael example from the nickle web page. I
> downloaded it into rijndael.5c and invoked nickle this way on sirius:
> 
> nickle rijndael.5c
> 
> I get this which looks like an error. Is it something I did?
> 
> --mark
> 
> -> rijndael.5c:191: Incompatible type, value 'int', for boolean
> -> rijndael.5c:191: Incompatible type, value 'int', for boolean
> ->     if (a && b)
> rijndael.5c:191: Incompatible types, left 'int', right 'int', for &&
> operation
> ->     if (key == 0 || key->direction != DIR_ENCRYPT || key->keyLen != 128
> && key->keyLen != 192 && key->keyLen != 256)
> rijndael.5c:672: Incompatible types, left '*keyInstance', right 'int', for
> == operation
> ->     if (cipher == 0 || cipher->mode != MODE_ECB && cipher->mode !=
> MODE_CBC && cipher->mode != MODE_CFB1 || cipher->blockLen != 128 &&
> cipher->blockLen != 192 && cipher->blockLen != 256)
> rijndael.5c:677: Incompatible types, left '*cipherInstance', right 'int',
> for == operation
> ->     if (cipher == 0 || key == 0 || key->direction == DIR_ENCRYPT ||
> cipher->blockLen != key->blockLen)
> rijndael.5c:748: Incompatible types, left '*cipherInstance', right 'int',
> for == operation
> ->     if (cipher == 0 || key == 0 || key->direction == DIR_ENCRYPT ||
> cipher->blockLen != key->blockLen)
> rijndael.5c:748: Incompatible types, left '*keyInstance', right 'int', for
> == operation
> ->     if (key == 0 || key->direction != DIR_DECRYPT || key->keyLen != 128
> && key->keyLen != 192 && key->keyLen != 256)
> rijndael.5c:757: Incompatible types, left '*keyInstance', right 'int', for
> == operation
> ->     if (cipher == 0 || cipher->mode != MODE_ECB && cipher->mode !=
> MODE_CBC && cipher->mode != MODE_CFB1 || cipher->blockLen != 128 &&
> cipher->blockLen != 192 && cipher->blockLen != 256)
> rijndael.5c:764: Incompatible types, left '*cipherInstance', right 'int',
> for == operation
> ->     if (cipher == 0 || key == 0 || cipher->blockLen != key->blockLen)
> rijndael.5c:861: Incompatible types, left '*cipherInstance', right 'int',
> for == operation
> ->     if (cipher == 0 || key == 0 || cipher->blockLen != key->blockLen)
> rijndael.5c:861: Incompatible types, left '*keyInstance', right 'int', for
> == operation
> -> rijndael.5c:918: Incompatible type, value 'int', for boolean
> ->     for (i = 0; i < dim (a) && a[i]; i++)
> rijndael.5c:918: Incompatible types, left 'bool', right 'int', for &&
> operation
> Unhandled exception "uninitialized_value" at rijndae
> 



More information about the Nickle mailing list