From 9d1e0c2dbbb4e917bfc5f417a319493f88e9e2a4 Mon Sep 17 00:00:00 2001 From: Mahrud Sayrafi Date: Wed, 11 Sep 2024 22:27:55 +0200 Subject: [PATCH] fixed getOptionBase, simplified getOptionDefaultValues --- M2/Macaulay2/m2/document.m2 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/M2/Macaulay2/m2/document.m2 b/M2/Macaulay2/m2/document.m2 index dec245a767..fad8ad660e 100644 --- a/M2/Macaulay2/m2/document.m2 +++ b/M2/Macaulay2/m2/document.m2 @@ -432,16 +432,17 @@ locate DocumentTag := tag -> new FilePosition from ( -- e.g. gb vs (codim, Ideal) getOptionBase := key -> ( if instance(key, Symbol) then key = value key; - try options key =!= null then key else try options key#0 =!= null then key#0 else key) + try if options key =!= null then return key; + try if options key#0 =!= null then return key#0; + key) emptyOptionTable := new OptionTable from {} -- TODO: this should return either an OptionTable or true, if any option is accepted getOptionDefaultValues := method(Dispatch => Thing) getOptionDefaultValues Thing := x -> emptyOptionTable getOptionDefaultValues Symbol := x -> if instance(f := value x, Function) then getOptionDefaultValues f else emptyOptionTable -getOptionDefaultValues Sequence := s -> if (opts := options s) === null then ( - if s#?0 and instance(s#0, Function) then getOptionDefaultValues s#0 else emptyOptionTable) else opts -getOptionDefaultValues Function := f -> if (opts := options f) === null then emptyOptionTable else opts +getOptionDefaultValues Sequence := s -> options s ?? getOptionDefaultValues s#0 ?? emptyOptionTable +getOptionDefaultValues Function := f -> options f ?? emptyOptionTable isType := T -> instance(T, Type) isTypeSignature := L -> instance(L, List) and all(L, isType)