From bart at keithp.com Fri Sep 5 22:18:20 2008 From: bart at keithp.com (Bart Massey) Date: Fri, 5 Sep 2008 22:18:20 -0700 (PDT) Subject: [Nickle] nickle: Branch 'master' Message-ID: <20080906051820.9E9FC1143DC@keithp.com> string.5c | 10 ++++++++++ value.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) New commits: commit 9a1ad39e7b3207925a807c27401450bd47d555d0 Author: Bart Massey Date: Fri Sep 5 22:18:08 2008 -0700 added string reverse() diff --git a/string.5c b/string.5c index 8f9af18..835dad9 100644 --- a/string.5c +++ b/string.5c @@ -252,4 +252,14 @@ extend namespace String { (quote_context) { .oq = "\"", .cq = "\"", .qq = "\""} ); + public string reverse(string s) + /* + * Reverse the string s + */ + { + int ns = length(s); + int[ns] t = { [i] = s[ns - i - 1] }; + return String::new(t); + } + } diff --git a/value.h b/value.h index 98c5845..cfdc64e 100644 --- a/value.h +++ b/value.h @@ -972,7 +972,7 @@ Value NewForeign (const char *id, void *data, void (*mark)(void *data), void (*f unsigned FpartLength (Fpart *a); -#define DEFAULT_FLOAT_PREC 256 +#define DEFAULT_FLOAT_PREC 4096 #define REF_CACHE_SIZE 1031 extern DataCachePtr refCache; From bart at po8.org Fri Sep 5 22:58:14 2008 From: bart at po8.org (bart at po8.org) Date: Fri, 05 Sep 2008 22:58:14 -0700 Subject: [Nickle] string_to_integer() behavior Message-ID: I note in passing that I was bitten just now by the fact that string_to_integer("09") == 0. I understand this behavior, but I'm not sure I like it. I note that string_to_integer("09", 10) == 9 as expected. Comments or suggestions? Bart From keithp at keithp.com Sat Sep 6 17:12:41 2008 From: keithp at keithp.com (Keith Packard) Date: Sat, 06 Sep 2008 17:12:41 -0700 Subject: [Nickle] nickle: Branch 'master' In-Reply-To: <20080906051820.9E9FC1143DC@keithp.com> References: <20080906051820.9E9FC1143DC@keithp.com> Message-ID: <1220746361.4845.270.camel@koto.keithp.com> On Fri, 2008-09-05 at 22:18 -0700, Bart Massey wrote: > diff --git a/value.h b/value.h > index 98c5845..cfdc64e 100644 > --- a/value.h > +++ b/value.h > @@ -972,7 +972,7 @@ Value NewForeign (const char *id, void *data, void (*mark)(void *data), void (*f > > unsigned FpartLength (Fpart *a); > > -#define DEFAULT_FLOAT_PREC 256 > +#define DEFAULT_FLOAT_PREC 4096 > #define REF_CACHE_SIZE 1031 > > extern DataCachePtr refCache; Did you intend to include this piece of the patch? -- keith.packard at intel.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From bart at keithp.com Sat Sep 6 22:44:26 2008 From: bart at keithp.com (Bart Massey) Date: Sat, 6 Sep 2008 22:44:26 -0700 (PDT) Subject: [Nickle] nickle: Branch 'master' Message-ID: <20080907054426.2D9D21143E1@keithp.com> value.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit c5dfef94042eedfd69d8bc110c7e2000f348efb1 Author: Bart Massey Date: Sat Sep 6 22:44:17 2008 -0700 reverted inadvertent change to DEFAULT_FLOAT_PREC diff --git a/value.h b/value.h index cfdc64e..98c5845 100644 --- a/value.h +++ b/value.h @@ -972,7 +972,7 @@ Value NewForeign (const char *id, void *data, void (*mark)(void *data), void (*f unsigned FpartLength (Fpart *a); -#define DEFAULT_FLOAT_PREC 4096 +#define DEFAULT_FLOAT_PREC 256 #define REF_CACHE_SIZE 1031 extern DataCachePtr refCache; From bart at keithp.com Sat Sep 6 22:45:43 2008 From: bart at keithp.com (Bart Massey) Date: Sat, 6 Sep 2008 22:45:43 -0700 (PDT) Subject: [Nickle] nickle: Branch 'master' Message-ID: <20080907054543.2900E1143E1@keithp.com> value.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit d24ae2f1bd182bd07eea8ef6918c3798c7d98393 Author: Bart Massey Date: Sat Sep 6 22:45:33 2008 -0700 replaced the copyright symbol in value.h, which had somehow become mangled diff --git a/value.h b/value.h index 98c5845..d5aa64c 100644 --- a/value.h +++ b/value.h @@ -1,7 +1,7 @@ /* $Header$ */ /* - * Copyright ? 1988-2007 Keith Packard and Bart Massey. + * Copyright ?? 1988-2007 Keith Packard and Bart Massey. * All Rights Reserved. See the file COPYING in this directory * for licensing information. */ From bart at po8.org Sat Sep 6 22:46:00 2008 From: bart at po8.org (Bart Massey) Date: Sat, 06 Sep 2008 22:46:00 -0700 Subject: [Nickle] nickle: Branch 'master' In-Reply-To: <1220746361.4845.270.camel@koto.keithp.com> References: <20080906051820.9E9FC1143DC@keithp.com> <1220746361.4845.270.camel@koto.keithp.com> Message-ID: In message <1220746361.4845.270.camel at koto.keithp.com> you wrote: > On Fri, 2008-09-05 at 22:18 -0700, Bart Massey wrote: > > -#define DEFAULT_FLOAT_PREC 256 > > +#define DEFAULT_FLOAT_PREC 4096 > > Did you intend to include this piece of the patch? Gah! No. Sorry. Reverted. Thanks much for the catch. Bart From bart at keithp.com Mon Sep 8 00:38:13 2008 From: bart at keithp.com (Bart Massey) Date: Mon, 8 Sep 2008 00:38:13 -0700 (PDT) Subject: [Nickle] nickle: Branch 'master' Message-ID: <20080908073813.811111143E5@keithp.com> builtin-toplevel.c | 8 ++++++++ builtin.c | 8 ++++++++ float.c | 13 ++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) New commits: commit 0eb425902db7e6291afb881086aef5a4a4e5019f Author: Bart Massey Date: Mon Sep 8 00:37:58 2008 -0700 added variable to control default floating point precision diff --git a/builtin-toplevel.c b/builtin-toplevel.c index 7a2236d..88d2cea 100644 --- a/builtin-toplevel.c +++ b/builtin-toplevel.c @@ -368,9 +368,17 @@ do_imprecise (int n, Value *p) } else { + Value float_prec; if (ValueIsFloat(v)) RETURN(v); prec = DEFAULT_FLOAT_PREC; + float_prec = lookupVar(0, "float_precision"); + if (float_prec) + { + int default_prec = ValueInt(float_prec); + if (default_prec > 1) + prec = default_prec; + } } RETURN (NewValueFloat (v, prec)); diff --git a/builtin.c b/builtin.c index 6f47c23..74d232b 100644 --- a/builtin.c +++ b/builtin.c @@ -51,6 +51,11 @@ static const struct filebuiltin fvars[] = { { 0, 0 }, }; +static const struct ibuiltin ivars[] = { + { DEFAULT_FLOAT_PREC, "float_precision", &GlobalNamespace }, + { 0, 0 }, +}; + static const struct ebuiltin excepts[] = { {"uninitialized_value", exception_uninitialized_value, "s", "\n" " uninitialized_value (string message)\n" @@ -373,6 +378,9 @@ BuiltinInit (void) BoxValueSet (sym->global.value, 0, *f->value); } + /* Import int objects with predefined values */ + BuiltinIntegers (ivars); + /* Import standard exceptions */ for (e = excepts; e->name; e++) BuiltinAddException (0, e->exception, e->name, e->args, e->doc); diff --git a/float.c b/float.c index 12af2ec..7dd3eea 100644 --- a/float.c +++ b/float.c @@ -579,10 +579,21 @@ FloatPromote (Value av, Value bv) if (!ValueIsFloat(av)) { + prec = DEFAULT_FLOAT_PREC; if (bv && ValueIsFloat(bv)) + { prec = bv->floats.prec; + } else - prec = DEFAULT_FLOAT_PREC; + { + Value float_prec = lookupVar(0, "float_precision"); + if (float_prec) + { + int default_prec = ValueInt(float_prec); + if (default_prec > 1) + prec = default_prec; + } + } av = NewValueFloat (av, prec); } RETURN (av);