From d4dde65a0f23cef213aa03dbbb85cd2504af5b6f Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 15 May 2013 00:40:43 +0000 Subject: * interp/define.boot (checkAndDeclare): Constructor parameter shadowing. * algebra/lodof.spad.pamphlet (SetOfMIntegersInOneToN): [enum]: Lose last parameter. Adjust callers. --- src/ChangeLog | 9 ++++++++- src/algebra/lodof.spad.pamphlet | 10 +++++----- src/interp/define.boot | 10 ++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 41ccaf39..e797f8b9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,11 @@ -2013-05-14 Gabriel Dos Reis +2013-05-14 Gabriel Dos Reis + + * interp/define.boot (checkAndDeclare): Constructor parameter + shadowing. + * algebra/lodof.spad.pamphlet (SetOfMIntegersInOneToN): [enum]: + Lose last parameter. Adjust callers. + +2013-05-14 Gabriel Dos Reis * interp/c-util.boot (cleanParameterList!): New. * interp/define.boot (spadCompileOrSetq): Use it. diff --git a/src/algebra/lodof.spad.pamphlet b/src/algebra/lodof.spad.pamphlet index d4247b25..1e102220 100644 --- a/src/algebra/lodof.spad.pamphlet +++ b/src/algebra/lodof.spad.pamphlet @@ -51,7 +51,7 @@ SetOfMIntegersInOneToN(m, n): Exports == Implementation where Rep := Record(bits:Bits, pos:N) reallyEnumerate: () -> Vector % - enum: (N, N, PI) -> List Bits + enum: (N, N) -> List Bits all:Reference Vector % := ref empty() sz:Reference N := ref 0 @@ -59,7 +59,7 @@ SetOfMIntegersInOneToN(m, n): Exports == Implementation where s1 = s2 == s1.bits =$Bits s2.bits coerce(s:%):OutputForm == brace [i::OutputForm for i in elements s] random() == index((1 + (random()$Integer rem size()))::PI) - reallyEnumerate() == [[b, i] for b in enum(m, n, n) for i in 1..] + reallyEnumerate() == [[b, i] for b in enum(m, n) for i in 1..] member?(p, s) == s.bits.p enumerate() == @@ -68,17 +68,17 @@ SetOfMIntegersInOneToN(m, n): Exports == Implementation where -- enumerates the sets of p integers in 1..q, returns them as sets in 1..n -- must have p <= q - enum(p, q, n) == + enum(p, q) == zero? p or zero? q => empty() p = q => b := new(n, false)$Bits for i in 1..p repeat b.i := true [b] q1 := (q - 1)::N - l := enum((p - 1)::N, q1, n) + l := enum((p - 1)::N, q1) if empty? l then l := [new(n, false)$Bits] for s in l repeat s.q := true - concat!(enum(p, q1, n), l) + concat!(enum(p, q1), l) size() == if zero? deref sz then diff --git a/src/interp/define.boot b/src/interp/define.boot index 89244baf..7228ea44 100644 --- a/src/interp/define.boot +++ b/src/interp/define.boot @@ -1768,11 +1768,13 @@ hasSigInTargetCategory(form,target,e) == first potentialSigList ++ Subroutine of compDefineCapsuleFunction. -checkAndDeclare(form,sig,e) == +checkAndDeclare(db,form,sig,e) == -- arguments with declared types must agree with those in sig; -- those that don't get declarations put into e for a in form.args for m in sig.source repeat isQuasiquote m => nil -- we just built m from a. + symbolMember?(a,dbParameters db) => + stackAndThrow('"Redeclaration of constructor parameter %1b",[a]) m1:= getArgumentMode(a,e) => not modeEqual(m1,m) => stack:= [" ",:bright a,'"must have type ",m, @@ -1826,8 +1828,8 @@ refineDefinitionSignature(form,signature,e) == signature' ++ Subroutine of compDefineCapsuleFunction. -processDefinitionParameters(form,signature,e) == - e := checkAndDeclare(form,signature,e) +processDefinitionParameters(db,form,signature,e) == + e := checkAndDeclare(db,form,signature,e) e := giveFormalParametersValues(form.args,e) e := addDomain(signature.target,e) e := compArgumentConditions e @@ -1901,7 +1903,7 @@ compDefineCapsuleFunction(db,df is ['DEF,form,signature,body], $formalArgList:= [:argl,:$formalArgList] signature := refineDefinitionSignature(form,signature,e) or return nil $signatureOfForm := signature --this global is bound in compCapsuleItems - e := processDefinitionParameters(form,signature,e) + e := processDefinitionParameters(db,form,signature,e) rettype := resolve(signature.target,$returnMode) localOrExported := -- cgit v1.2.3