From nickle@nickle.org  Wed Apr  2 07:52:45 2003
From: nickle@nickle.org (Bart Massey)
Date: Tue, 01 Apr 2003 23:52:45 -0800
Subject: [Nickle] File::end()
Message-ID: <E190d38-0000Ck-00@bart.cs.pdx.edu>

The fact that File::end(s) only returns true only after the
stream s has been read *past* end-of-file is really
confusing, just like it was in the old Pascal file pointer
days.  IMHO it should read ahead and unget the character if
it finds one.

	Bart


From nickle@nickle.org  Wed Apr  2 08:30:50 2003
From: nickle@nickle.org (Keith Packard)
Date: Wed, 02 Apr 2003 00:30:50 -0800
Subject: [Nickle] File::end()
In-Reply-To: Your message of "Tue, 01 Apr 2003 23:52:45 PST."
 <E190d38-0000Ck-00@bart.cs.pdx.edu>
Message-ID: <E190ddy-0007Io-00@localhost>

Around 23 o'clock on Apr 1, Bart Massey wrote:

> IMHO it should read ahead and unget the character if it finds one.

That may well block; I'm not sure you want that side-effect.

-keith




From nickle@nickle.org  Fri Apr 18 23:03:38 2003
From: nickle@nickle.org (Plutonium 186)
Date: Fri, 18 Apr 2003 22:03:38 +0000
Subject: [Nickle] continuation bug in nickle
Message-ID: <Law14-F39fKvcPPjsNE0000be57@hotmail.com>

The following code was intended as an example in the Nickle tutorial about 
continuations. It implements a simple binary tree search that longjmp()s out 
when the match is found; however, although longjmp() seems to be jumping 
somewhere (as evidenced by the debug statements), it does not jump to the 
setjmp() (as evidenced by the other debug statements). This seems like a 
bug.

-----
typedef tree;

typedef struct {
        int key;
        poly data;
        &poly left, right;
} tree;

void function search ( tree t, int i, &continuation c ) {
        if ( i < t.key && ! is_void ( t.left ) )
                search ( t.left, i, &c );
        else if ( i > t.key && ! is_void ( t.right ) )
                search ( t.right, i, &c );
        else if ( i == t.key ) {
                printf ( "key found\n" );
                longjmp ( c, t.data );
                assert(false, "longjmp failed\n" );
        }
}

tree t = { key = 2, data = "blah", left = reference ( <> ), right = 
reference ( <> ) };

continuation c;
int i = 0;
poly p = setjmp ( &c, <> );
++i;
printf ( "I have been here %d times.\n", i );

if ( is_void ( p ) )
        search ( t, 2, &c );
else
        printf ( "value = %g\n", p );
-----

Robert Burgess

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail



From nickle@nickle.org  Sun Apr 20 08:21:13 2003
From: nickle@nickle.org (Keith Packard)
Date: Sun, 20 Apr 2003 00:21:13 -0700
Subject: [Nickle] continuation bug in nickle
In-Reply-To: Your message of "Fri, 18 Apr 2003 22:03:38 -0000."
 <Law14-F39fKvcPPjsNE0000be57@hotmail.com>
Message-ID: <E19798T-000463-00@localhost>

Around 22 o'clock on Apr 18, "Plutonium 186" wrote:

> poly p = setjmp ( &c, <> );

You were fooled by nickle's bizarre top-level semantics.  Nickle compiles 
each top-level statement separately and runs them each in a separate 
thread.  What happened in the case you've included was that the longjump 
returned back to the point of the setjmp, but the code for that block 
ended at the end of the statement and didn't continue on to the following 
statements.

The problem is that nickle wants to execute the top level statements
independently so that interactive use is possible while you're expecting
the statements to be connected in some way, but separate compilation
prevents that from occuring naturally.  Restructure the code by placing the
top-level statements inside a single statement so that they are all
compiled together:

typedef tree;

typedef struct {
    int key;
    poly data;
    &poly left, right;
} tree;

void function search ( tree t, int i, &continuation c ) {
    if ( i < t.key && ! is_void ( t.left ) )
        search ( t.left, i, &c );
    else if ( i > t.key && ! is_void ( t.right ) )
        search ( t.right, i, &c );
    else if ( i == t.key ) {
        printf ( "key found\n" );
        longjmp ( c, t.data );
        assert(false, "longjmp failed\n" );
    }
}

tree t = { key = 2, data = "blah", left = reference ( <> ), right = 
    reference ( <> ) };

{
    continuation c;
    int i = 0;
    poly p = setjmp ( &c, <> );
    ++i;
    printf ( "I have been here %d times.\n", i );
    
    if ( is_void ( p ) )
        search ( t, 2, &c );
    else
        printf ( "value = %g\n", p );
}





From nickle@nickle.org  Tue Apr 22 22:28:06 2003
From: nickle@nickle.org (Jamey Sharp)
Date: Tue, 22 Apr 2003 14:28:06 -0700
Subject: [Nickle] files not auto-closed on exit?
Message-ID: <20030422212806.GX28020@sharp.ath.cx>

--JbaLeU65fPBt7QWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I have some nickle code that uses fprintf to write to a bunch of
different files, but at first I got only zero-length files. Bart glanced
at it and suggested I explicitly close the files, at which point I got
the output I expected. Bart says this is a bug.

(Hopefully) relevant excerpts:

import File;
void gen_test(file in, file out) {
    /* ... stuff happens here, then: */

    for (int i =3D 0; i < 7; i++) {
        nut x =3D spin_nut(nuts[i], spin[i]);
        fprintf(in, "%d", x[0]);
        for (int j =3D 1; j < 6; j++)
            fprintf(in, " %d", x[j]);
        fprintf(in, "\n");=20
    }
    close(in); /* added */

    for (int i =3D 0; i < 7; i++)=20
        fprintf(out, "%d %d\n", i + 1, spin[i] + 1);
    close(out); /* added */
}

for (int i =3D 1; i < 50; i++)
    gen_test(open(sprintf("In/%d", i), "w"), open(sprintf("Out/%d", i), "w"=
));

exit(0);
--=20
Jamey Sharp <jamey@minilop.net> - http://minilop.net/

--JbaLeU65fPBt7QWN
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+pbPmNgAXSpyH6VcRAhW5AJ0T4RDovnuHtOrtmNivVqMwlkDvxgCdEGe0
RSiYB3dsZgehFLmiUj4KI5w=
=Pg9t
-----END PGP SIGNATURE-----

--JbaLeU65fPBt7QWN--


From nickle@nickle.org  Tue Apr 22 22:58:40 2003
From: nickle@nickle.org (Bart Massey)
Date: Tue, 22 Apr 2003 14:58:40 -0700
Subject: [Nickle] files not auto-closed on exit?
In-Reply-To: Your message of "Tue, 22 Apr 2003 14:28:06 PDT."
 <20030422212806.GX28020@sharp.ath.cx>
Message-ID: <E1985mi-0003vK-00@bart.cs.pdx.edu>

The iffy bug is that one expects all files to be closed on
exit, at which point they are synced: I suppose that the
data is stuck in the Nickle heap on exit, having not been
flushed into stdio from whence it would be flushed to the OS
before normal program termination.  The question is whether
Nickle needs to keep a list of all the open files and
install an exit handler...

	Bart

In message <20030422212806.GX28020@sharp.ath.cx> you wrote:
> 
> --JbaLeU65fPBt7QWN
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> 
> I have some nickle code that uses fprintf to write to a bunch of
> different files, but at first I got only zero-length files. Bart glanced
> at it and suggested I explicitly close the files, at which point I got
> the output I expected. Bart says this is a bug.
> 
> (Hopefully) relevant excerpts:
> 
> import File;
> void gen_test(file in, file out) {
>     /* ... stuff happens here, then: */
> 
>     for (int i =3D 0; i < 7; i++) {
>         nut x =3D spin_nut(nuts[i], spin[i]);
>         fprintf(in, "%d", x[0]);
>         for (int j =3D 1; j < 6; j++)
>             fprintf(in, " %d", x[j]);
>         fprintf(in, "\n");=20
>     }
>     close(in); /* added */
> 
>     for (int i =3D 0; i < 7; i++)=20
>         fprintf(out, "%d %d\n", i + 1, spin[i] + 1);
>     close(out); /* added */
> }
> 
> for (int i =3D 1; i < 50; i++)
>     gen_test(open(sprintf("In/%d", i), "w"), open(sprintf("Out/%d", i), "w"=
> ));
> 
> exit(0);
> --=20
> Jamey Sharp <jamey@minilop.net> - http://minilop.net/
> 
> --JbaLeU65fPBt7QWN
> Content-Type: application/pgp-signature
> Content-Disposition: inline
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE+pbPmNgAXSpyH6VcRAhW5AJ0T4RDovnuHtOrtmNivVqMwlkDvxgCdEGe0
> RSiYB3dsZgehFLmiUj4KI5w=
> =Pg9t
> -----END PGP SIGNATURE-----
> 
> --JbaLeU65fPBt7QWN--
> 
> _______________________________________________
> Nickle mailing list
> Nickle@nickle.org
> http://nickle.org/mailman/listinfo/nickle


From nickle@nickle.org  Tue Apr 22 23:47:40 2003
From: nickle@nickle.org (Keith Packard)
Date: Tue, 22 Apr 2003 15:47:40 -0700
Subject: [Nickle] files not auto-closed on exit?
In-Reply-To: Your message of "Tue, 22 Apr 2003 14:58:40 PDT."
 <E1985mi-0003vK-00@bart.cs.pdx.edu>
Message-ID: <E1986Y8-0000aL-00@localhost>

Around 14 o'clock on Apr 22, Bart Massey wrote:

> I suppose that the data is stuck in the Nickle heap on exit, having not
> been flushed into stdio from whence it would be flushed to the OS before
> normal program termination.

Nickle can't use stdio as it doesn't have reliable indications of partial 
reads and writes, and breaks horribly on most systems when file 
descriptors are in non-blocking mode.

> The question is whether Nickle needs to keep a list of all the open files
> and install an exit handler...

It looks like Nickle needs some help with file management; it doesn't even 
flush files that are dropped when garbage collecting.

Suggestions for dealing with stalled output and other vageries are welcome.

-keith




From nickle@nickle.org  Thu Apr 24 21:32:28 2003
From: nickle@nickle.org (Bart Massey)
Date: Thu, 24 Apr 2003 13:32:28 -0700
Subject: [Nickle] Linux lab photo shoot Friday 4:00 PM
Message-ID: <E198nOO-0000iA-00@bart.cs.pdx.edu>

Tomorrow (April 25 2003) at 1600 a photographer will be in
the Linux Lab at PSU CS to take pictures for publicity
purposes.  It would be greatly appreciated if you could
attend to provide bodies for the photos.  Thanks,

	Bart Massey
	bart@cs.pdx.edu


