From nickle@nickle.org Wed Sep 4 04:38:23 2002 From: nickle@nickle.org (Sarah Williams) Date: Wed, 4 Sep 2002 11:38:23 +0800 Subject: [Nickle]HOME.KEITHP.COM Message-ID: <200209041633.g84GX5V16248@localhost> This is a multi-part message in MIME format --c1851f7c-f77f-4b94-80c5-00aca8f66d13 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi

I visited HOME.KEITHP.COM, and noticed that you're not listed on some search engines! I think we can offer = you a service which can help you increase traffic and the number of visitors = to your website.

I would like to introduce you to TrafficMagnet.com. We = offer a unique technology that will submit your website to over 300,000 search engines and directories = every month.

 

You'll be surprised by the low cost, and by how effective this website = promotion method can be.

To find out more about TrafficMagnet and the cost for submitting your = website to over 300,000 search engines and directories, visit www.TrafficMagnet.com.

I would love to hear from you.


Best Regards,

Sarah Williams
Sales and Marketing
E-mail: sarah_williams@trafficmagnet.com
http://www.TrafficMagnet.com=
--c1851f7c-f77f-4b94-80c5-00aca8f66d13-- From nickle@nickle.org Sat Sep 7 00:45:30 2002 From: nickle@nickle.org (Bart Massey) Date: Fri, 06 Sep 2002 16:45:30 -0700 Subject: [Nickle] bug: do-while doesnt Message-ID: int k = 0; do { k++; } while (k < 10); spins without incrementing k. Probably a compiler bug: I'll let Keith sort it out :-). Bart From nickle@nickle.org Sat Sep 7 01:05:33 2002 From: nickle@nickle.org (Keith Packard) Date: Fri, 06 Sep 2002 17:05:33 -0700 Subject: [Nickle] bug: do-while doesnt In-Reply-To: Your message of "Fri, 06 Sep 2002 16:45:30 PDT." Message-ID: Around 16 o'clock on Sep 6, Bart Massey wrote: > spins without incrementing k. Probably a compiler bug: I'll > let Keith sort it out :-). It incremented k *once*, but then it did kinda start spinning. Here's what the compiler was generating: LocalRefStore ^ auto k (link 0 elt 0) int k = 0; Const 0 Assign k++; LocalRef auto k (link 0 elt 0) PostOp + do while (k < 10); L1: Local ^ auto k (link 0 elt 0) Const 10 BinOp < BranchTrue branch L1 BranchModNone As you can see, it's branching back to the wrong place. It generated a branch back to the 'continue' portion of the loop, rather than the top. Easily fixed (and in CVS). -keith From nickle@nickle.org Wed Sep 11 09:36:39 2002 From: nickle@nickle.org (Bart Massey) Date: Wed, 11 Sep 2002 01:36:39 -0700 Subject: [Nickle] Nickle bug: import prettyprinting Message-ID: Looks like a prettyprinter problem with import statements. The code seems to work fine. > func(){ import String; return new(33); } func() { import x return new (33); } Bart From nickle@nickle.org Wed Sep 11 17:18:10 2002 From: nickle@nickle.org (Keith Packard) Date: Wed, 11 Sep 2002 09:18:10 -0700 Subject: [Nickle] Nickle bug: import prettyprinting In-Reply-To: Your message of "Wed, 11 Sep 2002 01:36:39 PDT." Message-ID: Around 1 o'clock on Sep 11, Bart Massey wrote: > Looks like a prettyprinter problem with import statements. Yup. It's a constant struggle to keep the pretty printer in sync with the parser. And, in this case, the parser actually discarded the optional public/protected clause which can proceed the 'import' keyword. Keith Packard XFree86 Core Team HP Cambridge Research Lab From nickle@nickle.org Fri Sep 13 20:16:13 2002 From: nickle@nickle.org (Bart Massey) Date: Fri, 13 Sep 2002 12:16:13 -0700 Subject: [Nickle] autoload, autoimport, Ctype Message-ID: I've added (with Keith's help) a bit of stuff to the Nickle distro that may be useful. The autoload command autoload NamespaceXXXStuff; looks for "namespace-xxxstuff.5c" on the (previously little-used) library_path. The autoimport command autoimport NamespaceXXXStuff; autoloads the namespace if necessary, then imports it. There is currently discussion about what the default library path should be. Suggestions are appreciated. I've also added a builtin Ctype module, with the same functionality as the C library version. It also allows you to define your own efficient ctype-like functions in terms of a "characteristic function". Ctype is ASCII-only: a UCtype library is planned for Unicode compatibility, as soon as I get around to it. Note that no C code was harmed in the creation of these modules: most new Nickle functionality can now be added in Nickle. This is a big win. Comments and bug reports appreciated. Bart Massey bart@cs.pdx.edu From nickle@nickle.org Mon Sep 16 17:23:59 2002 From: nickle@nickle.org (Carl Worth) Date: Mon, 16 Sep 2002 12:23:59 -0400 Subject: [Nickle] How to make min do the right thing? Message-ID: <15750.1439.119365.312422@scream.east.isi.edu> I've got what seems like the simplest of problems, but I'm looking for a little guidance. I've got: typedef struct { int a, b; } s; I want to define the following three functions for computing minimum values in the obvious ways: int mina(s list ...) { /* return minimum a value */ } int minb(s list ...) { /* return minimum b value */ } int min(int list ...) { /* return minimum arg value */ What's not obvious is what to do when any of these functions receive an empty list. Throwing an exception would seem natural, but it so happens that I have the following case in my algorithm: result = min(mina(foo ...), minb(bar ...)) where I "know" that either dim(foo) or dim(bar) may be 0, but never both. So, I wouldn't mind getting an exception from the outer min, but I don't want either of the inner calls to throw an exception; I just want them to do the right thing. In C I would use INT_MAX to get what I want, but of course that's not an option. I guess I could achieve a similar result by using a union to return either an int or a value that should compare greater than any int. Something like: typedef union { int val; void max; void min; } extremal; extremal mina(s list ...) { extremal min = extremal.max; for (int i=0; i < dim(list); i++) if (min == extremal.max || list[i].a < min.val) min.val = list[i].a; return min; } That's pretty good. It's still easy to use mina directly to get an int or a run-time exception as appropriate: mina(foo...).val And I can also rewrite min as: extremal min(extremal list ...) { /* return minimum arg value */ } so that I get exactly the behavior I want with: min(mina(foo...), minb(bar...)).val The only downside is that the "min" function is no longer easy to use with int arguments since it now only accepts arguments of type extremal. And the guts of the min functions aren't as elegant as I would wish since I can't use the relational operators with extremal values, (min is even a little uglier than mina above). Clearly I'm really wanting better polymorphism here. What think ye, am I getting close to the nicklest way of doing this? (At least with the present-day implementation). -Carl -- Carl Worth USC Information Sciences Institute cworth@east.isi.edu 3811 N. Fairfax Dr. #200, Arlington VA 22203 703-812-3725 From nickle@nickle.org Mon Sep 16 18:06:13 2002 From: nickle@nickle.org (Bart Massey) Date: Mon, 16 Sep 2002 10:06:13 -0700 Subject: [Nickle] How to make min do the right thing? In-Reply-To: Your message of "Mon, 16 Sep 2002 12:23:59 EDT." <15750.1439.119365.312422@scream.east.isi.edu> Message-ID: The other obvious alternative is to use (representing lists as arrays for convenience, ignoring the temporarily extraneous s structure, and coding the whole thing out so that we're clear on what's what) real min2(real emptymin, real[*] vals) { if (dim(vals) == 0) return emptymin; real m = vals[0]; for (int i = 1; i < dim(vals); i++) if (vals[i] < m) m = vals[i]; return m; } In this case real argmin(real[*] vals) { if (dim(vals) == 0) return -1; real m = vals[0]; int n = 0; for (int i = 1; i < dim(vals); i++) { if (vals[i] < m) { m = vals[i]; n = i; } } return n; } we should probably raise an exception on an empty input, since this is essentially an error condition, but by that logic so should String::index(), so what the heck. :-) Finally, "the Nickle way" to do what you originally wanted is probably to make an int list out of the arg list and apply one of the above functions to it: int min2a(int emptymin, s[*] vals) { int[dim(vals)] as = { [i] = vals[i].a }; return min2(emptymin, as); } Note that the return is only allowed by the type system because of our weirdo "implicit supertyping" rule, and that indeed, we know we're doing the right thing here. Interesting. Alternatively, although it's ugly now because of no parametric polymorphism, you could use the functional approach... poly[*] map(poly(poly) f, poly[*] vals) { poly[dim(vals)] result = { [i] = f(vals[i]) }; return result; } int min2a(int emptymin, s[*] vals) { return min2(emptymin, map(int func(s val) { return val.a; }, vals)); } Of course, the *really* functional approach would use compose() to get min2a from min2 and the lambda, but you get the idea... Programming with combinators is cool if you want to be really general, but kind of painful otherwise. Bart In message <15750.1439.119365.312422@scream.east.isi.edu> you wrote: > I've got what seems like the simplest of problems, but I'm looking for > a little guidance. > > I've got: > > typedef struct { > int a, b; > } s; > > I want to define the following three functions for computing minimum > values in the obvious ways: > > int mina(s list ...) { /* return minimum a value */ } > int minb(s list ...) { /* return minimum b value */ } > int min(int list ...) { /* return minimum arg value */ > > What's not obvious is what to do when any of these functions receive > an empty list. Throwing an exception would seem natural, but it so > happens that I have the following case in my algorithm: > > result = min(mina(foo ...), minb(bar ...)) > > where I "know" that either dim(foo) or dim(bar) may be 0, but never > both. So, I wouldn't mind getting an exception from the outer min, but > I don't want either of the inner calls to throw an exception; I just > want them to do the right thing. > > In C I would use INT_MAX to get what I want, but of course that's not > an option. > > I guess I could achieve a similar result by using a union to return > either an int or a value that should compare greater than any > int. Something like: > > typedef union { > int val; > void max; > void min; > } extremal; > > extremal mina(s list ...) > { > extremal min = extremal.max; > > for (int i=0; i < dim(list); i++) > if (min == extremal.max || list[i].a < min.val) > min.val = list[i].a; > > return min; > } > > That's pretty good. It's still easy to use mina directly to get an int > or a run-time exception as appropriate: > > mina(foo...).val > > And I can also rewrite min as: > > extremal min(extremal list ...) { /* return minimum arg value */ } > > so that I get exactly the behavior I want with: > > min(mina(foo...), minb(bar...)).val > > The only downside is that the "min" function is no longer easy to use > with int arguments since it now only accepts arguments of type > extremal. And the guts of the min functions aren't as elegant as I > would wish since I can't use the relational operators with extremal > values, (min is even a little uglier than mina above). Clearly I'm > really wanting better polymorphism here. > > What think ye, am I getting close to the nicklest way of doing this? > (At least with the present-day implementation). > > -Carl > > -- > Carl Worth > USC Information Sciences Institute cworth@east.isi.edu > 3811 N. Fairfax Dr. #200, Arlington VA 22203 703-812-3725 > > _______________________________________________ > Nickle mailing list > Nickle@nickle.org > http://nickle.org/mailman/listinfo/nickle From nickle@nickle.org Wed Sep 18 16:12:51 2002 From: nickle@nickle.org (Carl Worth) Date: Wed, 18 Sep 2002 11:12:51 -0400 Subject: [Nickle] How to make min do the right thing? In-Reply-To: References: <15750.1439.119365.312422@scream.east.isi.edu> Message-ID: <15752.38899.744591.356436@scream.east.isi.edu> On Sep 16, Bart Massey wrote: > The other obvious alternative is to use > > real min2(real emptymin, real[*] vals) { Thanks Bart. Passing in the return value for the degenerate case is a useful idea. It doesn't solve the entire problem, (since I still have to come up with a maximum value to pass in, which might be hard), but it at least pushes that aspect of the problem outside of a function as general as min should be. -Carl From nickle@nickle.org Wed Sep 18 16:12:56 2002 From: nickle@nickle.org (Carl Worth) Date: Wed, 18 Sep 2002 11:12:56 -0400 Subject: [Nickle] How to make min do the right thing? In-Reply-To: References: <15750.1439.119365.312422@scream.east.isi.edu> Message-ID: <15752.38904.78454.55564@scream.east.isi.edu> On Sep 16, Bart Massey wrote: > The other obvious alternative is to use > > real min2(real emptymin, real[*] vals) { Thanks Bart. Passing in the return value for the degenerate case is a useful idea. It doesn't solve the entire problem, (since I still have to come up with a maximum value to pass in, which might be hard), but it at least pushes that aspect of the problem outside of a function as general as min should be. -Carl From nickle@nickle.org Mon Sep 30 20:00:05 2002 From: nickle@nickle.org (Craig Dawson) Date: Mon, 30 Sep 2002 12:00:05 -0700 (PDT) Subject: [Nickle] Mac OS X Message-ID: <20020930190005.93047.qmail@web13901.mail.yahoo.com> Greetings, Has anyone done a build on Mac OS X? Thanks, Craig ===== --------------------------------- Craig Dawson at cxd@CraigDawson.org