From: John Benediktsson Date: Mon, 18 Sep 2023 22:40:38 +0000 (-0700) Subject: gml.core: use check-instance X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=f1e6e490ac85301c9b8f66d339334d1317fb0d28 gml.core: use check-instance --- diff --git a/extra/gml/core/core.factor b/extra/gml/core/core.factor index 66604e2bf3..e109e96387 100644 --- a/extra/gml/core/core.factor +++ b/extra/gml/core/core.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2010 Slava Pestov. -USING: gml.types gml.printer gml.runtime math ranges -continuations combinators arrays kernel vectors accessors -prettyprint fry sequences assocs locals hashtables grouping -sorting models ; +USING: accessors arrays assocs classes combinators continuations +gml.printer gml.runtime gml.types grouping hashtables kernel +math ranges sequences sorting ; IN: gml.core ! Tokens @@ -77,8 +76,7 @@ GML: sort-number-permutation ( array -- permutation ) zip-index sort-keys values ; ! Dictionaries -ERROR: not-a-dict object ; -: check-dict ( obj -- obj' ) dup hashtable? [ not-a-dict ] unless ; inline +: check-dict ( obj -- obj' ) hashtable check-instance ; inline GML: begin ( dict -- ) check-dict over dictionary-stack>> push ; GML: end ( -- ) dup dictionary-stack>> pop* ; @@ -105,9 +103,7 @@ GML: where ( key -- ? ) GML: currentdict ( -- dict ) dup current-dict ; GML: load ( name -- value ) over lookup-name ; -ERROR: not-a-name object ; - -: check-name ( obj -- obj' ) dup gml-name? [ not-a-name ] unless ; inline +: check-name ( obj -- obj' ) gml-name check-instance ; inline GML: def ( name value -- ) swap check-name pick current-dict set-at ; GML: edef ( value name -- ) check-name pick current-dict set-at ;