1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

233 commits

Author SHA1 Message Date
Andy Wingo
7081d4f981 rename <application> to <call>
* doc/ref/compiler.texi (The Scheme Compiler): Update docs.

* libguile/expand.h:
* libguile/expand.c:
* module/language/tree-il.scm: Rename <application> to <call>.  Change
  the external representation from (apply proc arg ...) to (call proc
  arg ...).

* libguile/memoize.c:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/brainfuck/compile-tree-il.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* test-suite/tests/tree-il.test: Update all callers.
2011-06-02 13:42:55 +02:00
Andy Wingo
e2ccab571e psyntax simplification
* module/ice-9/psyntax.scm (strip): Inline the and-map* definition to
  its one call site.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-05-05 23:07:37 +02:00
Andy Wingo
04b04af85a fix free-id=? for module-bound keywords
* module/ice-9/psyntax.scm (free-id=?): For identifiers that are
  resolved to the toplevel, check that the variables that they would
  resolve to are equal, instead of simply checking that the symbolic
  identifier names are equal.  Allows keywords to be bound, renamed,
  exported, excluded, etc.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-04-29 16:37:42 +02:00
Andy Wingo
aa5698fb53 eval-when matches situations symbolically
* module/ice-9/psyntax.scm (chi-when-list): Just match symbolically
  instead of lexically, so as not to tie the meaning of eval-when to the
  bindings of eval, load, compile, and expand.
2011-04-29 16:36:50 +02:00
Andy Wingo
b735d33b2b psyntax simplification
* module/ice-9/psyntax.scm (id-var-name): Just rely on multiple-values
  truncation.
2011-04-29 11:14:56 +02:00
Andy Wingo
d8f699e8eb inline fxops in psyntax
* module/ice-9/psyntax.scm (fx+, fx-, fx=, fx<): Given our lame lack of
  an inliner, inline these manually with identifier syntax.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-03-31 13:29:58 +02:00
Andy Wingo
f929b9e5ec allow definitions in with-syntax body
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
  as seems to be suggested by the R6RS.

* test-suite/tests/syncase.test ("with-syntax"): Add test.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-03-31 13:23:27 +02:00
Andy Wingo
4da326f25d chi-top-sequence defines macros before expanding other exps
* module/ice-9/psyntax.scm (chi-top-sequence): Manually inline
  eval-if-c&e into its two call sites; I found it hard to understand
  otherwise.  If the mode is just 'e, defer expansion of definitions and
  expressions until the end, so that they can be expanded in a context
  of all syntax expanders defined in the sequence.
2011-02-27 12:59:03 +01:00
Andy Wingo
4c2e13e548 psyntax: fold chi-top-sequence into chi-top
* module/ice-9/psyntax.scm (chi-top-sequence): Pull chi-top into the
  body of this toplevel begin expander.  This will let us do r6rs
  toplevel expansion correctly.
  (chi-top): Remove.
  (macroexpand): Dispatch to chi-top-sequence directly.
2011-02-27 12:59:03 +01:00
Andy Wingo
0f550375be unquote and unquote-splicing can split multiple expressions
* module/ice-9/psyntax.scm (quasiquote): Import new definition from
  upstream psyntax, to allow unquote and unquote-splicing to take
  multiple arguments.
  (unquote, unquote-splicing): Adapt to not require a particular syntax
  form.

* module/ice-9/psyntax-pp.scm: Regenerated.
2011-02-08 21:38:57 +01:00
Andy Wingo
05a5e5d6d0 toplevel vars added by syntax expansion are unbound
* module/ice-9/psyntax.scm (chi-top): When adding to the toplevel
  environment at compile-time, default to undefined variables, not
  variables defined to #f.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/boot-9.scm (module-add!): Add a new pre-modules version
  of this function, so we can add variables the environment, not just
  values.
  (module-define!): Use module-add!.
2011-01-31 21:09:20 +01:00
Andy Wingo
8f1870f20f syntax-violation uses lambda*, throws a structured message
* module/ice-9/psyntax.scm (syntax-violation): Use lambda* for subform
  arg. Instead of using scm-error, just throw to 'syntax-error with all
  we got.

* module/ice-9/psyntax-pp.scm (#{and-map*\ 37}): Regenerated.
2010-11-16 02:56:57 +01:00
Andy Wingo
381ccb0b89 more inlining in psyntax
* module/ice-9/psyntax.scm (make-wrap, wrap-marks, wrap-subst): Use
  identifier syntax here too.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-10-08 12:31:56 +02:00
Andy Wingo
cf45ff030c inline symbol? and vector? to opcodes, and a psyntax inlining tweak
* libguile/vm-i-scheme.c (symbol?, vector?): New
  instructions. Renumbered the rest.
* libguile/vm-i-system.c: Renumber instructions.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* module/ice-9/psyntax.scm (binding-type, binding-value): Define using
  macros so that we inline to car and cdr opcodes. Oh, for an inliner :)

* module/language/tree-il/compile-glil.scm (*primcall-ops*)
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*)
  (*effect+exception-free-primitives*): Add symbol? and vector?
  inlines.
2010-10-08 12:31:56 +02:00
Andy Wingo
44d65b23ce docstrings in syntax-rules
* module/ice-9/psyntax.scm (syntax-rules): Allow a docstring between the
  literals and the first clause.
2010-08-29 19:27:23 -07:00
Andy Wingo
8fad25c25f reindent psyntax.scm
* module/ice-9/psyntax.scm: Reindent.
2010-08-16 21:36:14 -07:00
Andy Wingo
565c8e30cd update comments in psyntax.scm
* module/ice-9/psyntax.scm: Update comments. Fix a couple of needless
  conses in and-map.

* module/ice-9/psyntax-pp.scm (#{and-map*\ 35}): Regen.
2010-08-16 21:36:14 -07:00
Andy Wingo
ab6becd47f fix (set! MACRO exp) hygiene
* module/ice-9/psyntax.scm (lookup): Reflow comment.
  (chi-top, syntax): Add comments about mod for lookup.
  (set!): Lookup the identifier in the module attached to its syntax
  object. In the (set! MACRO foo) case, after expanding the macro, chi
  the resulting expression with the empty wrap, as syntax-type
  does. Seems to fix the case where the expansion references
  lexically-bound variables.

* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/syncase.test: Add a bunch of tests.
2010-07-09 17:05:02 +02:00
Andy Wingo
7cdd1615e0 relax restriction on _ in literals
* module/ice-9/psyntax.scm: Relax restriction on _ in literals.

* module/ice-9/psyntax-pp.scm: Regen.
2010-06-21 21:47:42 +02:00
Andy Wingo
b78d91d517 syntax-case treats _ as placeholder
* module/ice-9/psyntax.scm (underscore?): New helper, like ellipsis?.
  (syntax-case): Treat the _ pattern as a matches-all pattern,
  disallowing it from the keyword list. Another well-thought part of the
  R6RS.
  ($sc-dispatch): Dispatch _ patterns.

* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/syncase.test ("_ is a placeholder"): Add a test.
2010-06-21 20:56:05 +02:00
Andy Wingo
37620f3f4e set! name (lambda ...) names the lambda
* module/ice-9/psyntax.scm (build-lexical-assignment)
  (build-global-assignment): Maybe name the RHS.

* module/ice-9/psyntax-pp.scm: Regenerated.

* module/ice-9/boot-9.scm (catch, with-throw-handler, throw): Rework to
  use set! instead of define! so that we get names.
2010-06-19 13:56:16 +02:00
Andy Wingo
bfccdcd530 add support for variable transformers: settable identifier syntax
* module/ice-9/psyntax.scm (set!): Handle variable transformers; though,
  they cannot produce definitions.
  (make-variable-transformer): New procedure.
  (identifier-syntax): Allow the R6RS form that makes variable
  transformers.

* module/ice-9/psyntax-pp.scm: Regenerated.

* doc/ref/r6rs.texi (R6RS Incompatibilities): Remove letrec* item, and
  add set! restriction.
2010-06-19 12:43:40 +02:00
Andy Wingo
5f8c55ce3b fix order of internal definitions
* module/ice-9/psyntax.scm (chi-body): Whoops, actually render internal
  definitions into a letrec* in the right order.
* module/ice-9/psyntax-pp.scm: Regenerate.

* test-suite/tests/syntax.test: Add some letrec* tests.
2010-06-17 14:39:32 +02:00
Andy Wingo
0f2b9f6252 internal definitions expand out to letrec* instead of letrec
* module/ice-9/psyntax.scm (chi-body): Internal definitions are now
  letrec* instead of letrec, following the R6RS.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-17 13:43:26 +02:00
Andy Wingo
826373a25d psyntax, primitive expander, and memoizer support for letrec*
* libguile/expand.c (expand_letrec_helper): Factor out common code.
  (expand_letrec): Use expand_letrec_helper.
  (expand_letrec_star): New primitive syntax: letrec*.

* libguile/memoize.c (memoize): Add memoizer support for in-order letrec
  (letrec*).

* module/ice-9/psyntax.scm (build-letrec): Another arg, `in-order?'.
  (chi-body): Adapt to build-letrec change. We don't yet use letrec* for
  internal definitions.
  (letrec): Adapt to build-letrec change.
  (letrec*): New expander.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-17 13:43:26 +02:00
Andy Wingo
fb6e61ca21 beginnings of letrec* support in the expander
* libguile/expand.h (SCM_EXPANDED_LETREC_IN_ORDER_P)
  (SCM_MAKE_EXPANDED_LETREC): Add a new field to letrec, in-order?. Will
  be used to support letrec*.

* libguile/expand.c (LETREC, expand_named_let, expand_letrec): Adapt
  code.

* module/language/elisp/compile-tree-il.scm (compile-pair):
* module/ice-9/psyntax.scm (build-named-let, build-letrec): Pass #f for
  in-order? to `make-letrec'.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/language/tree-il.scm: Add letrec-in-order? accessor.
  (parse-tree-il, unparse-tree-il): Parse and unparse an in-order?
  letrec as `letrec*'.
  (tree-il->scheme): Serialize letrec*.
2010-06-17 13:43:26 +02:00
Andy Wingo
d71cc612c3 fix lexical call naming bug
* module/ice-9/psyntax.scm: Fix bug in which the whole syntax object was
  being recorded as the name of the operator in a lexical call, instead
  of just the symbolic name.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-11 16:58:36 +02:00
Andy Wingo
750ae8b7b7 add syntax-source accessor
* module/ice-9/psyntax.scm: Add syntax-source accessor.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/boot-9.scm: Declare syntax-source.
2010-06-06 22:51:03 +02:00
Andy Wingo
f42d8bd8ff simplify macro representation in the wake of module hygiene changes
* module/ice-9/psyntax.scm (chi-install-global, chi-macro)
  (eval-local-transformer): Now that we handle module hygiene through
  syntax objects, there is no more need to record the current module
  when installing syntax transformers.

* module/ice-9/psyntax-pp.scm: Regenerated (trickily).

* libguile/_scm.h: Bump objcode version for macro representation change.

* libguile/macros.c (scm_macro_transformer): Adapt to change in macro
  representation.
2010-06-06 13:39:44 +02:00
Andy Wingo
9846796b6a fix module-hygiene corner case by relying more on syntax objects
* module/ice-9/psyntax.scm (chi-macro): Instead of assuming that output
  of a macro should be scoped relative to the module that was current
  when the macro was defined, allow the module information associated
  with the syntax object itself to pass through unmolested. Fixes bug
  29860.
  (datum->syntax): Propagate the module of the identifier through to the
  new syntax object, so that datum->syntax preserves module hygiene in
  addition to lexical hygiene.
  (include, include-from-path): Refactor to plumb though the hygiene
  information from the filename instead of the `include', allowing
  hygiene from the original caller of include-from-path to propagate
  through.

* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/syncase.test ("macro-generating macro"): Add test for
  bug 29860.
2010-06-06 13:00:59 +02:00
Andy Wingo
a96434cc33 source location propagation fixes in psyntax
* module/ice-9/psyntax.scm (syntax-type): Add some comments about source
  locations. In calls to chi-macro, pass the source location
  information. Propagate source location information when unpacking
  syntax objects.
  (chi-macro): Add a comment about source locations. Decorate output
  introduced by the macro with the source location of macro use.

* module/ice-9/psyntax-pp.scm: Regenerate.

Fixes bug #29817.
2010-06-05 19:40:43 +02:00
Andy Wingo
22cf27c815 fix procedure naming
* module/ice-9/psyntax.scm (define-expansion-accessors): New helper, to
  define accesors for a particular expansion data structure. Use it
  later to define lambda?, lambda-meta, and set-lambda-meta!.
  (maybe-name-value): Update to work with the newly defined accessors.
  (build-global-reference, build-let, build-named-let, build-letrec):
  Re-enable naming of procedures.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-02 16:07:11 +02:00
Andy Wingo
82c45730af lambda* usage in psyntax.scm
* module/ice-9/psyntax.scm (macroexpand): Use lambda*.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-20 13:28:25 +02:00
Andy Wingo
131ae7b49d remove *mode* fluid from psyntax
* module/ice-9/psyntax.scm: Remove the *mode* fluid. Whee :)
  (macroexpand): No need to bind aa *mode* fluid.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-20 12:54:47 +02:00
Andy Wingo
632ddbf02b iron out inconsistency between eval and compile expansion
* libguile/expand.c (expand_lambda_star_case): Harmonize with tree-il,
  expanding keywords to (aok? (kw name gensym) ...), not
  (aok? (kw . index) ...).

* libguile/memoize.c (memoize): Process the (kw name gensym) format into
  (kw . index).

* module/ice-9/psyntax.scm (build-lambda-case): Remove a
  compile-versus-eval special case.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-20 12:53:21 +02:00
Andy Wingo
a310a1d12e primitive-eval takes expanded, not memoized, source
* module/ice-9/eval.scm (primitive-eval):
* libguile/eval.c (scm_c_primitive_eval): Don't expect a memoized
  expression -- expect either raw source or an *expanded* expression. We
  handle memoization ourselves.

* libguile/expand.c (scm_macroexpand): Settle down into its proper name,
  "macroexpand", even as we comment that it is but a fleeting boot
  expander.
  (scm_macroexpanded_p): New predicate for expanded code.

* libguile/expand.h: Add scm_macroexpanded_p.

* libguile/memoize.c (scm_memoize_expression): Require that the
  expression be expanded.
  (scm_init_memoize): Don't alias memoize-expression to macroexpand.

* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm: Always produce macroexpanded expressions,
  and hand them to primitive-eval. No more calls to memoize-expression
  here.

* test-suite/tests/optargs.test: Remove some tests, as unfortunately we
  have no way to invoke the boot expander after boot.
2010-05-20 12:25:52 +02:00
Andy Wingo
bdf7759c2b psyntax produces "expanded" structures directly
* module/ice-9/psyntax.scm: Remove a number of eval-versus-compile
  cases, instead producing "expanded" structures directly, which happen
  to coincide with tree-il.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-20 00:01:10 +02:00
Andy Wingo
3d10018e7f expanded type constructors in psyntax
* module/ice-9/psyntax.scm (define-expansion-constructors): Define
  constructors for expanded types.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-19 23:37:27 +02:00
Andy Wingo
12922f0dd1 psyntax builds case-lambda expressions
* module/ice-9/psyntax.scm (build-case-lambda, build-lambda-case):
  Actually build case-lambda expressions, knowing that the memoizer will
  do the right thing.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-14 00:28:39 +02:00
Andy Wingo
4f692ace90 macro expanders return memoized expressions
* libguile/eval.c (scm_c_primitive_eval):
* module/ice-9/eval.scm (primitive-eval): Rely on the expander to
  produce a memoized expression. If the expression is already memoized,
  just pass it through (the equivalent of the old "noexpand" hack).

* libguile/memoize.c (scm_init_memoize): Initialize `memoize-expression'
  as the initial binding of `macroexpand'.

* libguile/modules.c (scm_module_transformer): Before modules are
  booted, look for `macroexpand', not `%pre-modules-transformer'.

* module/ice-9/boot-9.scm: No more %pre-modules-transformer. Loading
  psyntax extends `macroexpand'.
  (make-module): `macroexpand' is the default transformer.

* module/ice-9/psyntax.scm: No more `noexpand'.
  (top-level-eval-hook, local-eval-hook): Instead of annotating with
  noexpand, memoize the expression before handing it to primitive-eval.
  (macroexpand): No more noexpand hack -- in its place we have another
  hack, to memoize the result when running in eval mode.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-07 22:22:19 +02:00
Andy Wingo
f2d126801c psyntax no longer attempts to track (current-module)
* module/ice-9/psyntax.scm: Revert tracking of the current module while
  expanding toplevel sequences. Better to preserve lexical scoping
  (relative to the module of the original expression) and allow for @@
  to override it.

* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/syncase.test: Test module-changing with @@.
2010-05-06 22:42:44 +02:00
Andy Wingo
27cbec84da @@ generalized to arbitrary expressions.
* module/ice-9/psyntax.scm (@@): The RHS of an @@ is no longer
  restricted to be an identifier, it can be an arbitrary expression.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-06 22:42:44 +02:00
Andy Wingo
9365d8ad3a change form of @ and @@ psyntax handlers
* module/ice-9/psyntax.scm (@, @@): Take r and w args, and also return
  r, w, and s. Adapt callers.
2010-05-06 22:42:44 +02:00
Andy Wingo
807f7ab0ac add `expand' eval-when situation
* module/ice-9/psyntax.scm (chi-when-list, chi-top): Add an undocumented
  `expand' situation to eval-when, which will trigger at expand-time for
  toplevel expressions. Useful when you are expanding for eval, but need
  to do some side effect to affect the expander -- like defining a
  module.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-06 22:42:44 +02:00
Andy Wingo
9a74920905 add explanatory comment to chi-macro
* module/ice-9/psyntax.scm (chi-macro): Add comment.
2010-05-04 23:48:10 +02:00
Andy Wingo
fe58ead4a3 only ensure local vars for definitions during expansion when compiling
* module/ice-9/psyntax.scm (chi-top): Only modify the compile-time
  environment to indicate that there is a local binding if we are
  running in compile mode. Otherwise some eval-when things might not
  have gotten executed, and our current-module could be wrong.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-03 22:11:15 +02:00
Andy Wingo
a5e95abe9b metadata for syntax-rules, identifier-syntax, and define-macro macros
* module/ice-9/psyntax.scm (syntax-rules, identifier-syntax):
* module/ice-9/boot-9.scm (define-macro): Embed metadata into the macro
  transformer for use by documentation tools and the like.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-03-29 18:01:34 +02:00
Andy Wingo
1f51e2757c vectors of pairs in docstring position are metadata
* module/ice-9/psyntax.scm (chi-lambda-case, lambda): If we find a
  vector of pairs in the docstring position, interpret those pairs as
  additional metadata.

* module/ice-9/psytntax-pp.scm: Regenerated.
2010-03-25 14:19:25 +01:00
Andy Wingo
3785c5b276 psyntax supports multiple docstrings, merging lambda-case metadata
* module/ice-9/psyntax.scm (build-simple-lambda, build-case-lambda):
  Don't take a docstring, take a metadata alist. Don't bother annotating
  interpreted expressions with docstrings.
  (chi-simple-lambda): Take already-parsed metadata.
  (lambda): Parse out multiple docstrings as separate "documentation"
  entries in the "meta".
  (chi-lambda-case): Merge multiple "meta" entries among the various
  cases.
  (lambda*, case-lambda, case-lambda*): Receive "meta" clauses, not
  docstrings.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-03-25 14:15:16 +01:00
Ludovic Courtès
df0f529585 Make `include' tail-recursive.
* module/ice-9/psyntax.scm (include)[read-file]: Make tail-recursive.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-03-20 17:03:54 +01:00