From c4403c179e732a50e2b21a01469f0a38ea2d0187 Mon Sep 17 00:00:00 2001 From: Chouser Date: Sun, 15 Feb 2015 16:46:34 -0500 Subject: forth: Add support for & var-args --- forth/types.fs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'forth/types.fs') diff --git a/forth/types.fs b/forth/types.fs index 7675a5e..51f04ed 100644 --- a/forth/types.fs +++ b/forth/types.fs @@ -125,6 +125,8 @@ MalType% deftype MalFalse MalFalse new constant mal-false \ === protocol methods === / +0 constant trace + \ Used by protocol methods to find the appropriate implementation of \ themselves for the given object, and then execute that implementation. : execute-method { obj pxt -- } @@ -153,10 +155,10 @@ MalType% deftype MalFalse MalFalse new constant mal-false ." '" 1 throw endif + trace if ." Calling '" pxt >name name>string type ." ' on " obj mal-type @ type-name type cr endif cells swap MalTypeType-method-vals @ + @ ( xt ) - obj swap execute - ; + obj swap execute ; \ Extend a type with a protocol method. This mutates the MalTypeType \ object that represents the MalType being extended. @@ -313,13 +315,15 @@ deftype MalVector MalVector extend to-list - MalVector/list @ to-list ;; + MalVector/list @ ;; extend empty? MalVector/list @ MalList/count @ 0= mal-bool ;; extend mal-count MalVector/list @ MalList/count @ MalInt. ;; + extend mal= + MalVector/list @ swap m= ;; drop MalType% -- cgit v1.2.3