From aad7d4b28d9e27be0b52b26d7f474908c65a511b Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 3 Oct 2011 11:11:54 +0000 Subject: * interp/comp.lisp: Remove. * interp/setvart.boot: Remove setting of 'compiler' options. * interp/setvars.boot (setAsharpArgs): Remove. (describeAsharpArgs): Likewise. (setInputLibrary): Likewise. (setOutputLibrary): Likewise. (describeInputLibraryArgs): Likewise. (describeOutputLibraryArgs): Likewise. --- src/ChangeLog | 11 +++++ src/interp/Makefile.in | 3 +- src/interp/br-data.boot | 2 +- src/interp/br-op1.boot | 4 +- src/interp/br-saturn.boot | 2 +- src/interp/buildom.boot | 4 +- src/interp/c-util.boot | 2 + src/interp/comp.lisp | 102 -------------------------------------------- src/interp/define.boot | 2 +- src/interp/functor.boot | 2 +- src/interp/i-coerfn.boot | 10 ++--- src/interp/lisplib.boot | 2 +- src/interp/nruncomp.boot | 8 ++-- src/interp/setvars.boot | 83 ----------------------------------- src/interp/setvart.boot | 67 ----------------------------- src/interp/sys-utility.boot | 10 +++++ 16 files changed, 42 insertions(+), 272 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a98a5875..8c52fa09 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2011-10-03 Gabriel Dos Reis + + * interp/comp.lisp: Remove. + * interp/setvart.boot: Remove setting of 'compiler' options. + * interp/setvars.boot (setAsharpArgs): Remove. + (describeAsharpArgs): Likewise. + (setInputLibrary): Likewise. + (setOutputLibrary): Likewise. + (describeInputLibraryArgs): Likewise. + (describeOutputLibraryArgs): Likewise. + 2011-10-02 Gabriel Dos Reis * lisp/core.lisp.in: Do not use CCL in AxiomCore. diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in index 06a885c8..2377686c 100644 --- a/src/interp/Makefile.in +++ b/src/interp/Makefile.in @@ -70,7 +70,7 @@ OBJS= boot-pkg.$(FASLEXT) types.$(FASLEXT) \ cattable.$(FASLEXT) posit.$(FASLEXT) \ cformat.$(FASLEXT) clam.$(FASLEXT) \ clammed.$(FASLEXT) nlib.$(FASLEXT) \ - comp.$(FASLEXT) daase.$(FASLEXT) \ + daase.$(FASLEXT) \ pathname.$(FASLEXT) compat.$(FASLEXT) \ serror.$(FASLEXT) ptrees.$(FASLEXT) \ cparse.$(FASLEXT) cstream.$(FASLEXT) \ @@ -328,7 +328,6 @@ postpar.$(FASLEXT): macros.$(FASLEXT) bootlex.$(FASLEXT): preparse.$(FASLEXT) macros.$(FASLEXT) \ nlib.$(FASLEXT) sys-globals.$(FASLEXT) newaux.$(FASLEXT): macros.$(FASLEXT) -comp.$(FASLEXT): macros.$(FASLEXT) preparse.$(FASLEXT): fnewmeta.$(FASLEXT) fnewmeta.$(FASLEXT): parsing.$(FASLEXT) parsing.$(FASLEXT): metalex.$(FASLEXT) diff --git a/src/interp/br-data.boot b/src/interp/br-data.boot index 33cd85a4..3b372629 100644 --- a/src/interp/br-data.boot +++ b/src/interp/br-data.boot @@ -580,7 +580,7 @@ childArgCheck(argl, nargl) == and/[fn for x in argl for y in nargl for i in 0..] where fn() == x = y or constructor? opOf y => true - isSharpVar y => i = POSN1(y, $FormalMapVariableList) + isSharpVar y => i = symbolPosition(y,$FormalMapVariableList) false --computeDescendantsOf cat == diff --git a/src/interp/br-op1.boot b/src/interp/br-op1.boot index 492838bb..216e863d 100644 --- a/src/interp/br-op1.boot +++ b/src/interp/br-op1.boot @@ -982,14 +982,14 @@ evalDomainOpPred(dom,pred) == process(dom,pred) where p isnt [.,:.] or #p = 1 => MKQ p ['%list,MKQ first p,:[convertCatArg x for x in rest p]] evpred(dom,pred) == - k := POSN1(pred,$predicateList) => testBitVector(dom.3,k + 1) + k := valuePosition(pred,$predicateList) => testBitVector(dom.3,k + 1) evpred1(dom,pred) evpred1(dom,pred) == pred is [op,:argl] => op in '(AND and) => "and"/[evpred1(dom,x) for x in argl] op in '(OR or) => "or"/[evpred1(dom,x) for x in argl] op is 'NOT => not evpred1(dom,first argl) - k := POSN1(pred,$predicateList) => testBitVector(dom.3,k + 1) + k := valuePosition(pred,$predicateList) => testBitVector(dom.3,k + 1) op is 'HasAttribute => [arg,[.,a]] := argl attPredIndex := LASSOC(a,dom.2) diff --git a/src/interp/br-saturn.boot b/src/interp/br-saturn.boot index d7bba66f..238855a0 100644 --- a/src/interp/br-saturn.boot +++ b/src/interp/br-saturn.boot @@ -1620,7 +1620,7 @@ bcConform1 form == main where string? form => strconc('"_"",form,'"_"") STRINGIMAGE form stringChar(s,0) = char "#" => - (n := POSN1(form, $FormalFunctionParameterList)) => + (n := symbolPosition(form,$FormalFunctionParameterList)) => htSay form2HtString ($FormalMapVariableList . n) htSay '"\" htSay form diff --git a/src/interp/buildom.boot b/src/interp/buildom.boot index 1905714d..6af76e6a 100644 --- a/src/interp/buildom.boot +++ b/src/interp/buildom.boot @@ -124,8 +124,8 @@ compareSigEqual(s,t,dollar,domain) == t is '$ => dollar isSharpVar t => vector? domain => - instantiationArgs(domain).(POSN1(t,$FormalMapVariableList)) - domain.args.(POSN1(t,$FormalMapVariableList)) + instantiationArgs(domain).(symbolPosition(t,$FormalMapVariableList)) + domain.args.(symbolPosition(t,$FormalMapVariableList)) string? t and ident? s => (s := symbolName s; t) nil s is '$ => compareSigEqual(dollar,u,dollar,domain) diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index ca882986..795556da 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1721,6 +1721,8 @@ compAndDefine l == _*COMP370_-APPLY_* := "PRINT-AND-EVAL-DEFUN" backendCompile l +$compileDontDefineFunctions := true + ++ Subroutine of compileInteractive. compQuietly fn == _*COMP370_-APPLY_* := diff --git a/src/interp/comp.lisp b/src/interp/comp.lisp index ad6b6520..e69de29b 100644 --- a/src/interp/comp.lisp +++ b/src/interp/comp.lisp @@ -1,102 +0,0 @@ -;; Copyright (c) 1991-2002, The Numerical Algorithms Group Ltd. -;; All rights reserved. -;; Copyright (C) 2007-2008, Gabriel Dos Reis. -;; All rights reserved. -;; -;; Redistribution and use in source and binary forms, with or without -;; modification, are permitted provided that the following conditions are -;; met: -;; -;; - Redistributions of source code must retain the above copyright -;; notice, this list of conditions and the following disclaimer. -;; -;; - Redistributions in binary form must reproduce the above copyright -;; notice, this list of conditions and the following disclaimer in -;; the documentation and/or other materials provided with the -;; distribution. -;; -;; - Neither the name of The Numerical Algorithms Group Ltd. nor the -;; names of its contributors may be used to endorse or promote products -;; derived from this software without specific prior written permission. -;; -;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -; NAME: Compiler Utilities Package - -; PURPOSE: Comp is a modified version of Compile which is a preprocessor for -; calls to Lisp Compile. It searches for variable assignments that use -; (SPADLET a b). It allows you to create local variables without -; declaring them local by moving them into a PROG variable list. -; This is not an ordinary SPADLET. It looks and is used like a SETQ. -; This preprocessor then collects the uses and creates the PROG. -; -; SPADLET is defined in Macro.Lisp. -; -; Comp recognizes as new lambda types the forms ILAM, SPADSLAM, SLAM, -; and entries on $clamList. These cache results. ("Saving LAMbda".) -; If the function is called with EQUAL arguments, returns the previous -; result computed. -; -; The package also causes traced things which are recompiled to -; become untraced. - -(IMPORT-MODULE "macros") -(in-package "BOOT") - -(defparameter |$compileDontDefineFunctions| 'T) - -;;; Common Block section - -;; The following are used mainly in setvars.boot -(defun notEqualLibs (u v) - (if (string= u (library-name v)) (seq (close-library v) t) nil)) - -(defun |dropInputLibrary| (lib) - ;; Close any existing copies of this library on the input path - (setq input-libraries - (delete lib input-libraries :test #'notEqualLibs ))) - -(defun |openOutputLibrary| (lib) - (|dropInputLibrary| lib) - (setq output-library (open-library lib 't)) - (setq input-libraries (cons output-library input-libraries)) ) - -(defun |addInputLibrary| (lib) - (|dropInputLibrary| lib) - (setq input-libraries (cons (open-library lib) input-libraries)) ) - -;; used to be called POSN - but that interfered with a CCL function -(DEFUN POSN1 (X L) (position x l :test #'equal)) - -; Fluidize: Returns a list of fluid variables in X - -(DEFUN COMP\,FLUIDIZE (X) (COND - ((AND (IDENTP X) - (NE X '$) - (NE X '$$) - (char= #\$ (ELT (PNAME X) 0)) (NULL (DIGITP (ELT (PNAME X) 1)))) - (LIST 'FLUID X)) - ((ATOM X) X) - ((EQ (QCAR X) 'FLUID) X) - ('T (PROG (A B) - (SETQ A (COMP\,FLUIDIZE (QCAR X))) - (SETQ B (COMP\,FLUIDIZE (QCDR X))) - (COND ((AND (EQ A (QCAR X)) (EQ B (QCDR X))) - (RETURN X)) - ('T (RETURN (CONS A B)) )) ) ))) - -(defmacro PRELET (L) `(spadlet . ,L)) -(defmacro RELET (L) `(spadlet . ,L)) -(defmacro PRESET (L) `(spadlet . ,L)) -(defmacro RESET (L) `(spadlet . ,L)) diff --git a/src/interp/define.boot b/src/interp/define.boot index e0d4f9ea..f933a59e 100644 --- a/src/interp/define.boot +++ b/src/interp/define.boot @@ -629,7 +629,7 @@ expandType(lazyt,template,domform) == functorName is ":" => [functorName,first argl,expandTypeArgs(second argl,template,domform)] lazyt is ['local,x] => - n := POSN1(x,$FormalMapVariableList) + n := symbolPosition(x,$FormalMapVariableList) domform.(1 + n) [functorName,:[expandTypeArgs(a,template,domform) for a in argl]] diff --git a/src/interp/functor.boot b/src/interp/functor.boot index 21be836f..0a93ed7d 100644 --- a/src/interp/functor.boot +++ b/src/interp/functor.boot @@ -510,7 +510,7 @@ ConstantCreator u == ProcessCond(cond,e) == ncond := applySubst($pairlis,cond) - integer? POSN1(ncond,$NRTslot1PredicateList) => predicateBitRef(ncond,e) + valuePosition(ncond,$NRTslot1PredicateList) => predicateBitRef(ncond,e) cond TryGDC cond == diff --git a/src/interp/i-coerfn.boot b/src/interp/i-coerfn.boot index 7735ae5d..d1825ac3 100644 --- a/src/interp/i-coerfn.boot +++ b/src/interp/i-coerfn.boot @@ -81,7 +81,7 @@ coerceDmp1(u,source is [.,v1,S],target is [.,v2,T],v,w) == multfunc:= getFunctionFromDomain('_*,target,[target,target]) pat1:= [member(x,v) for x in v1] pat2:= [member(x,w) for x in v1] - pat3:= [member(x,v) and POSN1(x,v) for x in v2] + pat3:= [member(x,v) and valuePosition(x,v) for x in v2] for [e,:c] in u until not z repeat exp := vector [y for x in pat2 for y in VEC2LIST e | x] z:= coerceInt(objNewWrap([[exp,:c]],t),target) => @@ -97,7 +97,7 @@ coerceDmp2(u,source is [.,v1,S],target is [.,v2,T]) == one:= domainOne(T) plusfunc:= getFunctionFromDomain('_+,target,[target,target]) multfunc:= getFunctionFromDomain('_*,target,[target,target]) - pat:= [member(x,v1) and POSN1(x,v1) for x in v2] + pat:= [member(x,v1) and valuePosition(x,v1) for x in v2] for [e,:c] in u until not z repeat z:= coerceInt(objNewWrap(c,S),target) => li:= VEC2LIST e @@ -296,7 +296,7 @@ Dmp2Up(u, source is [dmp,vl,S],target is [up,var,T]) == plusfunc:= getFunctionFromDomain('_+,T,[T,T]) zero := getConstantFromDomain($Zero,T) x := nil - pos:= POSN1(var,vl) + pos := valuePosition(var,vl) for [e,:c] in u until not y repeat exp:= e.pos e1:= removeVectorElt(e,pos) @@ -442,7 +442,7 @@ Expr2Up(u,source is [Expr,S], target is [.,var,T]) == -- variable is a kernel - varKernel := kernels.(POSN1(var, v1)) + varKernel := kernels.(valuePosition(var, v1)) univFunc := getFunctionFromDomain("univariate", source, [source, kernelDom]) sup := ['SparseUnivariatePolynomial, source] @@ -1376,7 +1376,7 @@ Up2Dmp(u,source is ['UnivariatePolynomial,var,S], one:= domainOne(T) plusfunc:= getFunctionFromDomain('_+,target,[target,target]) multfunc:= getFunctionFromDomain('_*,target,[target,target]) - n:= #vl ; p:= POSN1(var,vl) + n:= #vl ; p:= valuePosition(var,vl) l1:= not (p=0) and [0 for m in 1..p] l2:= not (p=n-1) and [0 for m in p..n-2] for [e,:c] in u until not z repeat diff --git a/src/interp/lisplib.boot b/src/interp/lisplib.boot index 7e38ce42..27b67a68 100644 --- a/src/interp/lisplib.boot +++ b/src/interp/lisplib.boot @@ -74,7 +74,7 @@ predicateBitIndex(x,e) == u := simpBool transHasCode(x,e) u is 'T => 0 u = nil => -1 - p := POSN1(u,$NRTslot1PredicateList) => p + 1 + p := valuePosition(u,$NRTslot1PredicateList) => p + 1 not flag => pn(predicateBitIndexRemop x,true,e) systemError nil diff --git a/src/interp/nruncomp.boot b/src/interp/nruncomp.boot index 93bcebb4..74486621 100644 --- a/src/interp/nruncomp.boot +++ b/src/interp/nruncomp.boot @@ -125,7 +125,7 @@ NRTencode(x,y) == encode(x,y,true) where encode(x,compForm,firstTime) == -- to be encoded. ["NRTEVAL",NRTreplaceAllLocalReferences copyTree simplifyVMForm compForm] symbolMember?(x,$formalArgList) => - v := $FormalMapVariableList.(POSN1(x,$formalArgList)) + v := $FormalMapVariableList.(symbolPosition(x,$formalArgList)) firstTime => ["local",v] v x is "$" => x @@ -216,7 +216,7 @@ genDeltaEntry(opMmPair,e) == saveNRTdeltaListComp.first := compEntry u := [eltOrConst,'$,$NRTbase+$NRTdeltaLength-index] where index() == - (n:= POSN1(opModemapPair,$NRTdeltaList)) => n + 1 + (n := valuePosition(opModemapPair,$NRTdeltaList)) => n + 1 --n + 1 since $NRTdeltaLength is 1 too large $NRTdeltaList:= [opModemapPair,:$NRTdeltaList] $NRTdeltaListComp:=[nil,:$NRTdeltaListComp] @@ -277,7 +277,7 @@ NRTassignCapsuleFunctionSlot(op,sig) == sig := substitute('$,second($functorForm),sig) sig := [NRTgetLocalIndex x for x in sig] opModemapPair := [op,['_$,:sig],["T",implementation]] - POSN1(opModemapPair,$NRTdeltaList) => nil --already there + valuePosition(opModemapPair,$NRTdeltaList) => nil --already there $NRTdeltaList:= [opModemapPair,:$NRTdeltaList] $NRTdeltaListComp := [nil,:$NRTdeltaListComp] $NRTdeltaLength := $NRTdeltaLength+1 @@ -524,7 +524,7 @@ buildFunctor(db,sig,code,$locals,$e) == [['%store,['%tref,'$,i],v] for i in $NRTbase.. for v in $FormalMapVariableList for arg in args] if symbolMember?($NRTaddForm,$locals) then - addargname := $FormalMapVariableList.(POSN1($NRTaddForm,$locals)) + addargname := $FormalMapVariableList.(symbolPosition($NRTaddForm,$locals)) argStuffCode := [['%store,['%tref,'$,5],addargname],:argStuffCode] [['stuffDomainSlots,'$],:argStuffCode, :predBitVectorCode2,storeOperationCode] diff --git a/src/interp/setvars.boot b/src/interp/setvars.boot index ab05dbed..b16fb1da 100644 --- a/src/interp/setvars.boot +++ b/src/interp/setvars.boot @@ -357,89 +357,6 @@ displaySetVariableSettings(setTree,label) == '" to see what the options are for",:bright subname,'".",'"%l", '"For more information, issue",:bright '")help set",'"."] - --- See the section compiler in setvart.boot. --- --- Current Values of compiler Variables - --- Variable Description Current Value --- ----------------------------------------------------------------- --- output library in which to place compiled code --- input controls libraries from which to load compiled code --- args arguments for compiling AXIOM code --- -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete --- -DAxiom -Y $AXIOM/algebra - - - -setAsharpArgs arg == - arg = "%initialize%" => - $asharpCmdlineFlags := '"-O -Fasy -Fao -Flsp -laxiom -Mno-AXL__W__WillObsolete -DAxiom -Y $AXIOM/algebra" - arg = "%display%" => - $asharpCmdlineFlags - (null arg) or (arg = "%describe%") or (first arg = '_?) => - describeAsharpArgs() - $asharpCmdlineFlags := first(arg) - - -describeAsharpArgs() == - sayBrightly LIST ( - '"%b",'")set compiler args ",'"%d",_ - '"is used to tell AXIOM how to invoke the library compiler ",'"%l",_ - '" when compiling code for AXIOM.",'"%l",_ - '" The args option is followed by a string enclosed in double quotes.",'"%l",'"%l",_ - '" The current setting is",'"%l",'"%b",'"_"",$asharpCmdlineFlags,'"_"",'"%d") - - -setInputLibrary arg == - arg = "%initialize%" => - true - arg = "%display%" => - [LIBRARY_-NAME(u) for u in INPUT_-LIBRARIES] - (null arg) or (arg = "%describe%") or (first arg = '_?) => - describeInputLibraryArgs() - arg is [act, filename] and (act := selectOptionLC(act,'(add drop),nil)) => - act = 'add => addInputLibrary TRUENAME STRINGIMAGE filename - act = 'drop => dropInputLibrary TRUENAME STRINGIMAGE filename - setInputLibrary nil - - -setOutputLibrary arg == - -- Hack to avoid initialising libraries in KCL: - true => false - arg = "%initialize%" => - $outputLibraryName := nil - arg = "%display%" => - $outputLibraryName or '"user.lib" - (null arg) or (arg = "%describe%") or (first arg = '_?) => - describeOutputLibraryArgs() - not ONEP(#arg) => setOutputLibrary nil - -- If the file already exists then use the complete pathname to help - -- keep track of it in the case the user issues )cd commands. - if FILEP (fn := STRINGIMAGE first arg) then fn := TRUENAME fn - openOutputLibrary($outputLibraryName := fn) - - -describeOutputLibraryArgs() == - sayBrightly LIST ( - '"%b",'")set compiler output library",'"%d",_ - '"is used to tell the compiler where to place", '"%l",_ - '"compiled code generated by the library compiler. By default it goes",'"%l",_ - '"in a file called",'"%b", '"user.lib", '"%d", '"in the current directory." - ) - - -describeInputLibraryArgs() == - sayBrightly LIST ( - '"%b",'")set compiler input add library",'"%d",_ - '"is used to tell AXIOM to add", '"%b", '"library", '"%d", '"to",'"%l", - '"the front of the path which determines where compiled code is loaded from.",_ - '"%l", '"%b",'")set compiler input drop library",'"%d",_ - '"is used to tell AXIOM to remove", '"%b", '"library", '"%d", '%l,_ - '"from this path." - ) - - -- See the section expose in setvart.boot -- ---------------------- The expose Option ---------------------- diff --git a/src/interp/setvart.boot b/src/interp/setvart.boot index ab3fb77c..57c54667 100644 --- a/src/interp/setvart.boot +++ b/src/interp/setvart.boot @@ -59,73 +59,6 @@ $setOptions := '( (nobreak break query resume fastlinks) nobreak) -- needed to avoid possible startup looping --- Current Values of compiler Variables --- --- Variable Description Current Value --- ----------------------------------------------------------------- --- output library in which to place compiled code --- input controls libraries from which to load compiled code --- args arguments for compiling AXIOM code --- -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete --- -DAxiom -Y $AXIOM/algebra - (compiler - "Library compiler options" - interpreter - TREE - novar - --- ---------------------- The output Option ---------------------- --- --- Description: library in which to place compiled code - ((output - "library in which to place compiled code" - interpreter - FUNCTION - setOutputLibrary - NIL - htSetOutputLibrary) - --- ---------------------- The input Option ----------------------- --- --- Description: controls libraries from which to load compiled code --- --- )set compiler input add library is used to tell AXIOM to add --- library to the front of the path which determines where --- compiled code is loaded from. --- )set compiler input drop library is used to tell AXIOM to remove --- library from this path. - (input - "controls libraries from which to load compiled code" - interpreter - FUNCTION - setInputLibrary - NIL - htSetInputLibrary) - --- ----------------------- The args Option ----------------------- --- --- Description: arguments for compiling AXIOM code --- --- )set compiler args is used to tell AXIOM how to invoke the --- library compiler when compiling code for AXIOM. --- The args option is followed by a string enclosed in double --- quotes. --- --- The current setting is --- "-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete --- -DAxiom -Y $AXIOM/algebra" - (args - "arguments for compiling AXIOM code" - interpreter - FUNCTION - setAsharpArgs - (("enter compiler options " - STRING - $asharpCmdlineFlags - chkDirectory - "-O -Fasy -Fao -Flsp -laxiom -Mno-AXL__W__WillObsolete -DAxiom -Y $AXIOM/algebra")) - NIL))) - -- ---------------------- The expose Option ---------------------- -- -- Description: control interpreter constructor exposure diff --git a/src/interp/sys-utility.boot b/src/interp/sys-utility.boot index b39a800c..b8ae514d 100644 --- a/src/interp/sys-utility.boot +++ b/src/interp/sys-utility.boot @@ -43,6 +43,8 @@ module sys_-utility where remove!: (%List %Thing,%Thing) -> %List %Thing displayTextFile: %Thing -> %Void upwardCut: (%Thing, %List %Thing) -> %List %Thing + symbolPosition: (%Symbol,%List %Symbol) -> %Maybe %Short + valuePosition: (%Thing,%List %Thing) -> %Maybe %Short --% $COMBLOCKLIST := nil @@ -346,6 +348,14 @@ subString(s,f,n == nil) == n = nil => subSequence(s,f) subSequence(s,f,f + n) +++ Return the position of the symbol `s' in the list `l', if present. +++ Otherwise return nil. +symbolPosition(s,l) == + or/[i for i in 0.. for x in l | symbolEq?(s,x)] + +valuePosition(s,l) == + or/[i for i in 0.. for x in l | valueEq?(s,x)] + --% assoc symbolAssoc(s,l) == -- cgit v1.2.3