On 04/19/2014 10:59 PM, Marc Feeley wrote:
What is it you expect from a tree-shaker?
The compiler already implements a tree-shaker, but it is experimental and not documented.
If you want to try it out do
gsc -c -e "(set! c#targ-tree-shake? #t)" shake.scm
Say shake.scm is the file
(declare (block))
(define (f x) (g (+ x 1)))
(define (g x) (* x x))
(define (h x) (f 11))
(f 22)
If you check the file shake.c that is generated, you will see that there is no code for function h and also no code for function g (because it is inlined in f).
This is an old thread, but it's interesting.
When I compiled Meroon recently with the tree-shaker, I got
-rwxrwxr-x 1 lucier lucier 800496 Mar 28 23:39 _meroon.o1*
while without the tree-shaker, I get
-rwxrwxr-x 1 lucier lucier 1111768 Mar 28 23:40 _meroon.o2*
That's not a trivial difference.
And there are unused, redundant things in Meroon (experimental dispatchers, etc.).
But when I load Meroon I get
(load "_meroon.o1")
*** WARNING -- Variable "Class-add-subclass" used in module "_meroon" is undefined *** WARNING -- Variable "Class-generate-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Class-generate-accompanying-functions" used in module "_meroon" is undefined *** WARNING -- Variable "Class-is-a?" used in module "_meroon" is undefined *** WARNING -- Variable "Class-super-class" used in module "_meroon" is undefined *** WARNING -- Variable "Class?" used in module "_meroon" is undefined *** WARNING -- Variable "Field?" used in module "_meroon" is undefined *** WARNING -- Variable "Generic-1-update!" used in module "_meroon" is undefined *** WARNING -- Variable "Generic-1?" used in module "_meroon" is undefined *** WARNING -- Variable "Generic-N-update!" used in module "_meroon" is undefined *** WARNING -- Variable "Generic-N?" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-augment-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-compress-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-enlarge-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-find-method" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-rebalance-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher-update-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Global-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-accompanying-functions" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-allocator" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-coercer" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-maker" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class-generate-predicate" used in module "_meroon" is undefined *** WARNING -- Variable "Handy-Class?" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher-augment-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher-compress-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher-find-method" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher-rebalance-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher-update-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Immediate-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher-augment-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher-compress-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher-find-method" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher-rebalance-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher-update-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Indexed-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "Linear-Dispatcher-find-multi-method" used in module "_meroon" is undefined *** WARNING -- Variable "Linear-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "MeroonV2-Class-generate-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "MeroonV2-Class?" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-compute-value-offset" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-create-careful-reader" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-create-careful-writer" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-field-defined?" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-field-value" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-Handy-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-MeroonV2-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-fast-careful-reader" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-fast-careful-writer" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-next-offset!" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-generate-offset" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-initialize-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field-set-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Mono-Field?" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-compute-value-offset" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-create-careful-lengther" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-create-careful-reader" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-create-careful-writer" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-field-defined?" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-field-length" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-field-value" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-Handy-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-MeroonV2-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-fast-careful-lengther" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-fast-careful-reader" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-fast-careful-writer" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-next-offset!" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-generate-offset" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-initialize-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field-set-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Poly-Field?" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher-augment-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher-compress-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher-find-method" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher-rebalance-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher-update-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Subclass-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "Tracing-Dispatcher-augment-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Tracing-Dispatcher-compress-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Tracing-Dispatcher-rebalance-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Tracing-Dispatcher-update-dispatcher!" used in module "_meroon" is undefined *** WARNING -- Variable "Tracing-Dispatcher?" used in module "_meroon" is undefined *** WARNING -- Variable "View-generate-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "View-generate-accompanying-functions" used in module "_meroon" is undefined *** WARNING -- Variable "View-generate-predicate" used in module "_meroon" is undefined *** WARNING -- Variable "View-is-a?" used in module "_meroon" is undefined *** WARNING -- Variable "View?" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-compute-value-offset" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-field-defined?" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-field-length" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-field-value" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-generate-Handy-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-generate-MeroonV2-accessors" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-initialize-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field-set-field-value!" used in module "_meroon" is undefined *** WARNING -- Variable "Virtual-Field?" used in module "_meroon" is undefined> (show Object-class)
*** WARNING -- Variable "add-1-method!" used in module "_meroon" is undefined *** WARNING -- Variable "add-N-method!" used in module "_meroon" is undefined *** WARNING -- Variable "adjust-index" used in module "_meroon" is undefined *** WARNING -- Variable "already-unveiled?" used in module "_meroon" is undefined *** WARNING -- Variable "barfing-method" used in module "_meroon" is undefined *** WARNING -- Variable "careless-determine-method1" used in module "_meroon" is undefined *** WARNING -- Variable "careless-subclass?" used in module "_meroon" is undefined *** WARNING -- Variable "check-appropriate-size" used in module "_meroon" is undefined *** WARNING -- Variable "check-class" used in module "_meroon" is undefined *** WARNING -- Variable "check-conformity" used in module "_meroon" is undefined *** WARNING -- Variable "check-index" used in module "_meroon" is undefined *** WARNING -- Variable "check-revision" used in module "_meroon" is undefined *** WARNING -- Variable "check-size" used in module "_meroon" is undefined *** WARNING -- Variable "coherent-variables?" used in module "_meroon" is undefined *** WARNING -- Variable "collect-super-class-numbers" used in module "_meroon" is undefined *** WARNING -- Variable "combine" used in module "_meroon" is undefined *** WARNING -- Variable "compare-signatures" used in module "_meroon" is undefined *** WARNING -- Variable "compare4egal" used in module "_meroon" is undefined *** WARNING -- Variable "compute-offset" used in module "_meroon" is undefined *** WARNING -- Variable "copy-vector-slice!" used in module "_meroon" is undefined *** WARNING -- Variable "count-Poly-Fields" used in module "_meroon" is undefined *** WARNING -- Variable "create-Indexed-Dispatcher" used in module "_meroon" is undefined *** WARNING -- Variable "create-Mono-Field" used in module "_meroon" is undefined *** WARNING -- Variable "create-Poly-Field" used in module "_meroon" is undefined *** WARNING -- Variable "create-allocator" used in module "_meroon" is undefined *** WARNING -- Variable "create-default-generic-method" used in module "_meroon" is undefined *** WARNING -- Variable "create-one-final-poly-maker" used in module "_meroon" is undefined *** WARNING -- Variable "create-some-field" used in module "_meroon" is undefined *** WARNING -- Variable "create-zero-poly-maker" used in module "_meroon" is undefined *** WARNING -- Variable "display-meroon-anomaly" used in module "_meroon" is undefined *** WARNING -- Variable "display-meroon-banner" used in module "_meroon" is undefined *** WARNING -- Variable "every?" used in module "_meroon" is undefined *** WARNING -- Variable "extend-Indexed-Dispatcher" used in module "_meroon" is undefined *** WARNING -- Variable "extend-classes-number!" used in module "_meroon" is undefined *** WARNING -- Variable "fill-instance!" used in module "_meroon" is undefined *** WARNING -- Variable "find-method1" used in module "_meroon" is undefined *** WARNING -- Variable "find-option-plus-values" used in module "_meroon" is undefined *** WARNING -- Variable "find-option-present?" used in module "_meroon" is undefined *** WARNING -- Variable "find-option-single-value" used in module "_meroon" is undefined *** WARNING -- Variable "general-make" used in module "_meroon" is undefined *** WARNING -- Variable "generate-class-name" used in module "_meroon" is undefined *** WARNING -- Variable "generate-lengther-name" used in module "_meroon" is undefined *** WARNING -- Variable "generate-reader-name" used in module "_meroon" is undefined *** WARNING -- Variable "generate-writer-name" used in module "_meroon" is undefined *** WARNING -- Variable "get-new-class-number" used in module "_meroon" is undefined *** WARNING -- Variable "get-new-generic-number" used in module "_meroon" is undefined *** WARNING -- Variable "globalize-dispatcher" used in module "_meroon" is undefined *** WARNING -- Variable "goto-margin" used in module "_meroon" is undefined *** WARNING -- Variable "identity" used in module "_meroon" is undefined *** WARNING -- Variable "implements?" used in module "_meroon" is undefined *** WARNING -- Variable "instance-clone" used in module "_meroon" is undefined *** WARNING -- Variable "internal-meroon-error" used in module "_meroon" is undefined *** WARNING -- Variable "iota" used in module "_meroon" is undefined *** WARNING -- Variable "last-pair" used in module "_meroon" is undefined *** WARNING -- Variable "look-generic" used in module "_meroon" is undefined *** WARNING -- Variable "look4keyword" used in module "_meroon" is undefined *** WARNING -- Variable "make-maker" used in module "_meroon" is undefined *** WARNING -- Variable "meroon-keyword-eq?" used in module "_meroon" is undefined *** WARNING -- Variable "meroon-reduce" used in module "_meroon" is undefined *** WARNING -- Variable "oo-error" used in module "_meroon" is undefined *** WARNING -- Variable "option-not-there" used in module "_meroon" is undefined *** WARNING -- Variable "propagate-super-methods!" used in module "_meroon" is undefined *** WARNING -- Variable "really-indexize-dispatcher" used in module "_meroon" is undefined *** WARNING -- Variable "register-Generic-1" used in module "_meroon" is undefined *** WARNING -- Variable "register-method" used in module "_meroon" is undefined *** WARNING -- Variable "remove" used in module "_meroon" is undefined *** WARNING -- Variable "remove-option" used in module "_meroon" is undefined *** WARNING -- Variable "report-already-initialized" used in module "_meroon" is undefined *** WARNING -- Variable "report-bad-coercion-to-field" used in module "_meroon" is undefined *** WARNING -- Variable "report-bad-index" used in module "_meroon" is undefined *** WARNING -- Variable "report-immutable-field" used in module "_meroon" is undefined *** WARNING -- Variable "report-meroon-error" used in module "_meroon" is undefined *** WARNING -- Variable "report-missing-index" used in module "_meroon" is undefined *** WARNING -- Variable "report-superfluous-allocation" used in module "_meroon" is undefined *** WARNING -- Variable "report-uninitialized-field" used in module "_meroon" is undefined *** WARNING -- Variable "resolve-virtual-field" used in module "_meroon" is undefined *** WARNING -- Variable "retrieve-named-field" used in module "_meroon" is undefined *** WARNING -- Variable "reverse!" used in module "_meroon" is undefined *** WARNING -- Variable "sequence-find" used in module "_meroon" is undefined *** WARNING -- Variable "sequence-map" used in module "_meroon" is undefined *** WARNING -- Variable "show-already-unveiled-object" used in module "_meroon" is undefined *** WARNING -- Variable "show-field" used in module "_meroon" is undefined *** WARNING -- Variable "show-index" used in module "_meroon" is undefined *** WARNING -- Variable "show-list" used in module "_meroon" is undefined *** WARNING -- Variable "show-unveiled" used in module "_meroon" is undefined *** WARNING -- Variable "show-unveiled-list-content" used in module "_meroon" is undefined *** WARNING -- Variable "show-unveiled-vector-content" used in module "_meroon" is undefined *** WARNING -- Variable "show-vector" used in module "_meroon" is undefined *** WARNING -- Variable "simple-append-fields" used in module "_meroon" is undefined *** WARNING -- Variable "skip2next-keyword" used in module "_meroon" is undefined *** WARNING -- Variable "symbol->class" used in module "_meroon" is undefined *** WARNING -- Variable "symbol->generic" used in module "_meroon" is undefined *** WARNING -- Variable "symbol-concatenate" used in module "_meroon" is undefined *** WARNING -- Variable "vector-extend" used in module "_meroon" is undefined [ Meroon V3 Paques2001+1 $Revision: 1.2 $ ] "/home/lucier/programs/MeroonV3-2015Mar04/_meroon.o1"
(define-class Point (Object) (x y))
*** ERROR -- Unbound variable: check-and-process-class-definition
Meroon is written in Meroon (with a bootstrap step, initial classes and objects constructed by hand, etc.)
So it appears that the compiler included in the library onl those routines actively used to build Meroon.
If Gambit had a proper module system, perhaps the compiler could include all routines needed by the exported procedures and macros.
Now *that* would be cool.
Brad