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

222 commits

Author SHA1 Message Date
Andy Wingo
24bf130fd1 implement #:predicate
will be useful for making e.g. typecase-lambda. Tough to tell though.

* module/ice-9/psyntax.scm (lambda-formals, lambda*-formals): Parse out
  a #:predicate, which goes right before the rest args. The vanilla
  lambda doesn't parse it out of course, but it does return another
  value.
  (chi-lambda-case, lambda*, lambda): Expand and pass the predicate on
  to build-lambda-case.

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

* module/language/tree-il/compile-glil.scm (flatten): Compile a failing
  predicate without an else clause into a call to `error'. Also, fix
  something the compile warnings caught.
2009-10-26 21:20:35 +01:00
Andy Wingo
647117cd35 case-lambda, case-lambda* in psyntax
* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Add
  implementations of these, present in the base environment.

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

* module/srfi/srfi-16.scm (case-lambda): Replace the core's case-lambda
  definition with our own. We're not quite ready to switch yet.
2009-10-25 13:12:27 +01:00
Andy Wingo
c89222f8ce refactor psyntax.scm's treatment of lambda and lambda*
* module/ice-9/psyntax.scm (lambda-formals, chi-simple-lambda)
  (lambda*-formals, chi-lambda-case): Refactor the lambda
  transformations with an eye to being able to do case-lambda.

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

* test-suite/tests/syntax.test: Adapted tests so that the errors we
  expect match what is given by psyntax.
2009-10-25 12:36:44 +01:00
Andy Wingo
97bc28b60a define* in psyntax
* module/ice-9/optargs.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm: Make define* available in the default
  environment, as lambda* is available there.
2009-10-24 16:32:27 +02:00
Andy Wingo
df1cd5e59b lambda* in psyntax
* module/ice-9/psyntax.scm (build-lambda-case): Take an "inits" arg.
  Also work around a nasty memoizer bug: see
  http://article.gmane.org/gmane.lisp.guile.devel/9561.
  (lambda*): Implement in psyntax, in the default environment. Exciting
  stuff!

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

* module/ice-9/optargs.scm (parse-lambda-case): Helper for lambda* when
  we're running under the interpreter.
2009-10-23 16:51:43 +02:00
Andy Wingo
b0c8c187d9 separate "inits" field in <lambda-case>; compile fixes for inits, kwargs
* module/language/tree-il.scm (<lambda-case>): Add "inits" field, so we
  don't have to parse it out of opt and kw. Adapt the traversal
  procedures.
* module/language/tree-il/analyze.scm (analyze-lexicals): Analyze
  lexicals in the <lambda-case> init expressions as well. Fix keyword
  allocation.

* module/language/tree-il/compile-glil.scm (compile-glil): Adapt to
  make-lambda-case change.
  (flatten): Adapt to "inits" slot, actually init uninitialized args,
  and fix bugs related to keyword arguments.

* module/language/tree-il/inline.scm (inline!): Adapt a little bit --
  but with no effect.

* module/language/glil/compile-assembly.scm (glil->assembly): Flesh out
  <glil-kw-prelude> compilation some more. Add a "bound?" op for
  <glil-lexical>, which will push #t if the local is bound.

* module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case):
  Update for new signature of make-lambda-case.
* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/brainfuck/compile-tree-il.scm (compile-body):
* module/language/ecmascript/compile-tree-il.scm (comp):
* test-suite/tests/tree-il.test ("lambda"): Update for new lambda-case
  syntax.
2009-10-23 16:48:05 +02:00
Andy Wingo
899d37a6cf more work towards compiling and interpreting keyword args
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bumparoo
* libguile/vm-i-system.c (push-rest, bind-rest): Logically there are
  actually two rest binders -- one that pops, conses, and pushes, and
  one that pops, conses, and local-sets. The latter is used on keyword
  arguments, because the keyword arguments themselves have been shuffled
  up on the stack. Renumber ops again.

* module/language/tree-il/compile-glil.scm (flatten): Attempt to handle
  compilation of lambda-case with keyword arguments. Might need some
  help.

* module/ice-9/psyntax.scm (build-lambda-case): An attempt to handle the
  interpreted case correctly. This might need a couple iterations, but
  at least it looks like the compile-glil code.

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

* module/language/glil.scm (<glil>): Rename "rest?" to "rest" in
  <glil-opt-prelude> and <glil-kw-prelude>, as it is no longer a simple
  boolean, but if true is an integer: the index of the local variable to
  which the rest should be bound.

* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
  "rest" vs "rest?". In the keyword case, use "bind-rest" instead of
  "push-rest".

* test-suite/tests/tree-il.test: Update for opt-prelude change.
2009-10-23 15:20:22 +02:00
Andy Wingo
8a4ca0ea3b tree-il support for case-lambda
* module/language/tree-il.scm (<lambda>, <lambda-case>): Split lambda
  into the lambda itself, denoting the procedure, and lambda-case,
  denoting a particular arity case. Lambda-case is fairly featureful,
  and has not yet been fully tested.
  (<let-values>): Use a <lambda-case> as the binding expression. Seems
  to suit the purpose well.
  Adapt parsers, unparsers, traversal operators, etc. Sometimes in this
  first version we assume there are no optional args, rest args, or a
  predicate.

* module/language/tree-il/analyze.scm (analyze-lexicals): Adapt for the
  new case-lambda regime. Fairly well commented. It actually simplifies
  things.
  (report-unused-variables): Update for new tree-il.

* module/language/tree-il/compile-glil.scm: Adapt for the new tree-il.
  There are some first stabs here at proper case-lambda compilation, but
  they are untested as of yet.

* module/language/tree-il/inline.scm (inline!): Rework so we can
  recurse on a single node; though these transformations are strictly
  reductive, so they should complete in bounded time. Simplify
  accordingly, and adapt to case-lambda. Oh, and we handle lambda->let
  in not just the nullary case.

* module/ice-9/psyntax.scm (build-simple-lambda, build-case-lambda)
  (build-lambda-case): New constructors. The idea is that after syntax
  expansion, we shouldn't have to deal with improper lists any more.
  Build-simple-lambda is a shortcut for the common case. The others are
  not fully exercised yet. Adapt callers.
  (syntax): Add some debugging in the lambda case. I don't fully
  understand this, but in practice we don't seem to see rest args here.
  (lambda): Inline chi-lambda-clause, and adapt for build-simple-lambda.
* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/tree-il.test: Update tests for new tree-il lambda
  format, and to expect post-prelude labels for all glil programs.
2009-10-23 15:10:25 +02:00
Julian Graham
416c9fb363 Fix typo in psyntax.scm related to syntax-violation reporting.
* module/ice-9/psyntax.scm (chi-macro): Replace `s' with `(wrap-subst w)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2009-10-19 22:44:52 +02:00
Ludovic Courtès
b9434165b6 Allow redefinitions in compiled code as in `(define round round)'.
* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/psyntax.scm (chi-top)[define-form]: If a same-named
  imported variable exists, take its value instead of `#f'.

* test-suite/tests/compiler.test ("psyntax")["redefinition"]: New tests.
2009-08-13 15:50:37 +02:00
Andy Wingo
d95eb7f49f fix gensym creation in psyntax
* module/ice-9/psyntax.scm (build-lexical-var): Make our gensyms really
  unique. Before, there was a chance that different lexicals could
  result in the same gensym.
* module/ice-9/psyntax-pp.scm: Regenerate.
2009-07-24 12:06:19 +02:00
Andy Wingo
89cb70a0d5 fix source information lossage for (define (foo) ...) lambda sugar
* module/ice-9/psyntax.scm (source-wrap): Use decorate-source, for
  clarity.
  (syntax-type): When turning the RHS of (define (foo) ...) into a
  lambda, decorate the resulting lambda expression with source
  information, as the RHS later goes to chi-expr, which receives no
  source information. Perhaps that is a bug. In any case, fixes some
  source location lossage, reported by Jao.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-06-20 12:41:11 +02:00
Andy Wingo
fc5b616b58 source information for the interpreter
* module/ice-9/psyntax.scm: Try to propagate source information when
  generating output for the interpreter.

* module/ice-9/psyntax-pp.scm: Regenerate.
2009-06-20 10:47:37 +02:00
Andy Wingo
65dd9e3846 pretty-print psyntax-pp.scm
* module/ice-9/compile-psyntax.scm: Pretty-print psyntax-pp.scm, given
  that we are going to compile it anyway.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-06-08 22:44:01 +02:00
Andy Wingo
55dce020bd fix bootstrapping after last night's psyntax patch
* module/Makefile.am (ice-9/psyntax-pp.scm): Don't try autocompiling when
  making psyntax-pp.scm.

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

* module/ice-9/psyntax.scm (chi-top): Only affect the compile-time
  environment if modules have booted.
2009-06-08 01:04:16 +02:00
Andy Wingo
c0ee32452f fix incorrect inlining of + when + is locally redefined
* libguile/vm-i-scheme.c (FUNC2): Use a signed value for the intermediate
  result here. Not sure what the effect is, though.

* module/ice-9/psyntax.scm (chi-top): Toplevel definitions ensure that
  variables are defined in the current module. Fixes the specific case of
  guile-lib's md5.scm, which redefines + -- this code is needed so that
  we don't incorrectly open-code +.

* module/language/tree-il/primitives.scm (resolve-primitives!): I think
  there were some cases in which vars and names would not resolve
  properly here. Fix those.
2009-06-07 00:53:48 +02:00
Andy Wingo
a23c940b71 support ((@ ...) ...) where the car is a macro
* module/ice-9/psyntax.scm (syntax-type): Remove `external-macro', not
  used any more. Take an extra arg, `for-car?', indicating that we're
  checking on the type of a form in the car position. In the case that
  the expression is a pair, do a full recursion on the car, which allows
  us to catch the fact that the car of the following form is a macro:
     ((@ (ice-9 optargs) let-optional) ...)
  and thus the form itself should be macroexpanded.

  But, since we want to distingush `lambda' from `(lambda ...)', just as
  we have global and global-call, we have core to the new `core-form'.

  (chi-top, chi, chi-expr, chi-body, set!): Adapt to changes to
  syntax-type.
2009-06-06 00:30:05 +02:00
Andy Wingo
0e7b72a8fe source location tracking in psyntax, booya!
* module/ice-9/psyntax.scm (source-annotation): Return #f if
  source-properties returns null.
  (source-wrap): Rework a bit.
  (syntax-type): Don't throw away source info for wrapped expressions.
  Can has source location info, fools!
  (chi-body): Correctly propagate source info for body subforms.
  (syntax): Remove special case for map, it doesn't apply (ahem) for
  Guile.

* module/ice-9/psyntax-pp.scm: Regenerate.
2009-05-22 21:12:42 +02:00
Andy Wingo
b40d023067 remove annotations in psyntax in favor of guile's source properties
* module/ice-9/psyntax.scm: Remove references to annotation objects,
  we're just going to try and use Guile's source properties now. It works
  until `syntax' reconstructs output, at which point it seems we lose it.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-05-22 19:48:14 +02:00
Andy Wingo
39a2eca2ce fix problem naming internal definitions
* module/ice-9/psyntax.scm (chi-body): Fix a problem introduced in
  dc1eed52f7, that internal syntax definitions were included in the id
  lis along with value definitions. Only showed up on a second bootstrap.
  Psyntax, how I love thee.

* module/ice-9/psyntax-pp.scm
2009-05-22 19:26:58 +02:00
Andy Wingo
dc1eed52f7 residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
  from the SRFI itself. Yuk.
  (%print-module, make-modules-in, %app, (%app modules))
  (module-name): Syncase needs to get at the names of modules, even at
  anonymous modules. So lazily assign gensyms as module names. Name %app
  as (%app), but since (%app modules) is at the top of the module
  hierarchy, name it ().

* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
  definitions and in lets.
  (let, letrec): Give more specific errors in a couple of cases.

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

* test-suite/tests/syntax.test: More work. Many exceptions have different
  messages than they used to, many more generic; we can roll this back to
  be faithful to the original strings, but it doesn't seem necessary to
  me.
2009-05-22 12:08:50 +02:00
Andy Wingo
0260421208 some work on syntax.test
* module/language/tree-il.scm (tree-il->scheme):
* module/ice-9/psyntax.scm (build-conditional): Attempt to not generate
  (if #f #f) as the second arm of an if, but it doesn't seem to be
  successful.

* module/ice-9/psyntax-pp.scm (syntax-rules): Regenerate.

* test-suite/tests/syntax.test (exception:unexpected-syntax): Change
  capitalization.
  ("unquote-splicing"): Update test.
  ("begin"): Add in second arms on these ifs, to avoid the strange though
  harmless expansion of `if'.
  (matches?): New helper macro.
  ("lambda"): Match on lexically bound symbols, as they will be
  alpha-renamed.
2009-05-21 22:43:07 +02:00
Andy Wingo
40b36cfbbe catch syntax errors in unquote and unquote-splicing
* module/ice-9/psyntax.scm (quasiquote): Catch syntax errors in unquote
  and unquote-splicing.

* module/ice-9/psytax-pp.scm: Regenerated.
2009-05-21 22:11:48 +02:00
Andy Wingo
8bb0b3cc9d fix failing macro-as-parameter tests in eval.test
* module/ice-9/psyntax.scm (chi-lambda-clause): Strip the docstring
  before passing it on to the continuation.

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

* test-suite/tests/eval.test (exception:failed-match): New exception, for
  syntax-case failed matches.
  ("evaluator"): Fix macro-as-parameter tests. They pass now :)
2009-05-20 18:11:23 +02:00
Andy Wingo
e32a1792de a few fixups
* module/ice-9/psyntax.scm (chi-install-global, syntax-case): Fix a
  couple of cases in which bare datums were passed to output
  constructors.

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

* module/language/scheme/spec.scm (scheme): Clean up the #:compilers
  list.

* module/language/tree-il/compile-glil.scm (flatten): Fix call to
  `length' in call/cc compiler.
2009-05-20 11:59:41 +02:00
Andy Wingo
a1a482e0e9 and, or, cond etc use syntax-rules, compile scheme through tree-il
* libguile/vm-i-system.c:
* libguile/vm-engine.h (ASSERT_BOUND): New assertion, that a value is
  bound. Used by local-ref and external-ref in paranoid mode.

* module/ice-9/boot-9.scm (and, or, cond, case, do): Since we are
  switching to use psyntax as the first pass of the compiler, and perhaps
  soon of the interpreter too, we need to make sure it expands out all
  forms to primitive expressions. So define expanders for these derived
  syntax forms, as in the R5RS report.

* module/ice-9/psyntax-pp.scm: Regenerate, with core forms fully
  expanded.

* module/ice-9/psyntax.scm (build-void): New constructor, for making
  undefined values.
  (build-primref): Add in a hack so that primitive refs in the boot
  module expand out to toplevel refs, not module refs.
  (chi-void): Use build-void.
  (if): Define an expander for if that calls build-conditional.

* module/language/scheme/compile-tree-il.scm (compile-tree-il): Use let*
  so as not to depend on binding order for the result of
  (current-module).

* module/language/scheme/spec.scm (scheme): Switch over to tree-il as the
  primary intermediate language. Not yet fully tested, but at least it
  can compile psyntax-pp.scm.

* module/language/tree-il/analyze.scm (analyze-lexicals): Arguments don't
  count towards a function's nlocs.

* module/language/tree-il/compile-glil.scm (*comp-module*, compile-glil):
  Define a "compilation module" fluid.
  (flatten-lambda): Fix a call to make-glil-argument. Fix bug in
  heapifying arguments.
  (flatten): Fix number of arguments passed to apply instruction. Add a
  special case for `(values ...)'. If inlining primitive-refs fails,
  try expanding into toplevel-refs if the comp-module's variable is the
  same as the root variable.

* module/language/tree-il/optimize.scm (resolve-primitives!): Add missing
  src variable for <module-ref>.

* test-suite/tests/tree-il.test ("lambda"): Fix nlocs counts. Add a
  closure test case.
2009-05-20 11:15:22 +02:00
Andy Wingo
1eec95f8de define `delay' in terms of make-promise
* module/ice-9/boot-9.scm (delay): Define `delay' in terms of
  make-promise.

* module/ice-9/psyntax-pp.scm (compile): Regenerated with a fully
  compiled Guile, so that the gensym numbers are the same.

* module/language/tree-il/compile-glil.scm: Add some notes about what
  needs doing to catch up to the old compiler.
2009-05-17 18:04:36 +02:00
Andy Wingo
696495f4d2 actually pass original ids on to tree-il data types
* module/ice-9/psyntax.scm (build-lambda, build-let, build-named-let)
  (build-letrec): Actually pass along the original ids to tree-il
  constructors.

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

* module/language/tree-il.scm: Add fields in <lambda>, <let>, and
  <letrec> for the original variable names.

* module/language/tree-il/compile-glil.scm (compile-glil): Adapt for new
  make-lambda arg.
2009-05-17 16:39:55 +02:00
Andy Wingo
547a602d1e preserve original var names in lets and lambdas
* module/ice-9/psyntax.scm (build-letrec, build-let, build-lambda)
  (build-named-let): Take extra args for the original names of the
  gensyms. Not used yet. Callers adapted.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-05-17 16:27:18 +02:00
Andy Wingo
06656e06d4 go ahead and regenerate psyntax-pp.scm 2009-05-07 17:44:51 +02:00
Andy Wingo
811d10f5a2 new language: tree-il. psyntax generates it when run in compile mode.
* module/Makefile.am: Add tree-il sources.

* module/ice-9/compile-psyntax.scm: Adjust for sc-expand producing
  tree-il in compile mode.

* module/ice-9/psyntax.scm: Switch from expand-support to tree-il for
  generating output in compile mode. Completely generate tree-il -- the
  output wasn't Scheme before, but now it's completely not Scheme.

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

* module/language/scheme/compile-ghil.scm: Strip structures using
  tree-il, not expand-support.

* module/language/tree-il.scm:
* module/language/tree-il/spec.scm
* module/language/tree-il/compile-glil.scm: New language. It will compile
  to GLIL, though it doesn't yet.
2009-05-07 17:32:01 +02:00
Andy Wingo
1aeb082b82 make expand-support structure constructors take a source argument
* module/ice-9/expand-support.scm (make-module-ref, make-lexical): Add
  source arguments to these constructors.

* module/ice-9/psyntax.scm:
* module/ice-9/psyntax-pp.scm: Adapt to match, though we don't wire
  everything up yet.
2009-05-07 11:02:10 +02:00
Andy Wingo
f27e9e11cd fix install-global construction of `define' forms
* module/ice-9/psyntax.scm (build-global-definition): Remove mod
  argument, as it does not seem we could ever define something in another
  module.
  (chi-install-global): Build the define as a definition, not an
  application. Doesn't matter now, but it will later.
  (chi-top): Fix build-global-definition call.

* module/ice-9/psyntax.scm: Regenerated.
2009-05-07 10:27:53 +02:00
Andy Wingo
f4a644ee88 when compiling, use make-lexical to residualize original var names
* module/ice-9/psyntax.scm (build-lexical-reference): Change to be a
  function. Take an extra arg, the original name of the variable. If we
  are compiling, make a #<lexical>, annotated with the original var name.
  All callers changed.
  (build-lexical-assignment): Also a function, taking also the original
  var name, using build-lexical-reference to build its output.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-05-04 12:18:14 +02:00
Andy Wingo
71f46dbd5e sc-expand in compile mode produces (ice-9 expand-support) structures
* module/ice-9/psyntax.scm (*mode*): New moving part, a fluid.
  (sc-expand): Dynamically bind *mode* to the expansion mode.
  (build-global-reference): Change to be a procedure instead of local
  syntax. Import the logic about when to make a @ or @@ form to here,
  from boot-9.scm. If we are compiling, build output using (ice-9
  expand-support)'s make-module-ref, otherwise just making the familiar
  s-expressions. (This will allow us to correctly expand in modules in
  which @ or @@ are not bound, at least when we are compiling.)
  (build-global-assignment): Use the result of build-global-reference. A
  bit hacky, but hey.
  (top-level-eval-hook, local-eval-hook): Strip expansion structures
  before evalling.

* module/ice-9/boot-9.scm (make-module-ref): Remove, this logic is now
  back in psyntax.scm.

* module/ice-9/compile-psyntax.scm (source): Since we expand in compile
  mode, we need to strip expansion structures.

* module/ice-9/expand-support.scm (strip-expansion-structures): Remove
  the logic about whether and how to strip @/@@ from here, as it's part
  of psyntax now.

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

* module/language/scheme/compile-ghil.scm (compile-ghil): Strip expansion
  structures -- for now. In the future, we might translate directly from
  these structures into GHIL.
2009-05-04 11:57:36 +02:00
Andy Wingo
123f8abb2d replace sc-expand with sc-expand3, removing binding for sc-expand3
* module/ice-9/boot-9.scm (sc-expand3):
* module/ice-9/psyntax.scm (sc-expand3): Replace sc-expand with
  sc-expand3, as expand3 with one argument is the same as sc-expand.

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

* module/ice-9/compile-psyntax.scm:
* module/language/scheme/compile-ghil.scm: Change callers to sc-expand3
  to use sc-expand.
2009-05-04 10:47:31 +02:00
Andy Wingo
41af238146 remove (void) from boot-9 and psyntax
* module/ice-9/psyntax.scm: Tweak comments. Remove references to `void';
  just produce (if #f #f) instead of (void).

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

* module/ice-9/boot-9.scm (void): Remove this binding.
2009-04-29 23:57:31 +02:00
Andy Wingo
6a952e0ee9 more cleanups to boot-9/psyntax
* module/ice-9/boot-9.scm: Comment some more things.

* module/ice-9/psyntax.scm: Remove error-hook -- callers should just use
  syntax-violation. Change all callers.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-29 23:39:09 +02:00
Andy Wingo
4d24854111 remove andmap from public API (we still have and-map)
* module/ice-9/boot-9.scm (and-map, or-map): Move these definitions up so
  psyntax can use them.
  (andmap): Remove, yay.

* module/ice-9/psyntax.scm: Remove notes about andmap, and just use
  Guile's and-map -- except in cases that need the multiple list support,
  in which case we have a private and-map*.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-29 23:12:12 +02:00
Andy Wingo
12eae603c7 cleanups to boot-9
* module/ice-9/boot-9.scm: Shuffle around some definitions.
  (module-add!): Removed stub definition, no longer used.
  (install-global-transformer): Removed, no longer used (yay!).

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

* module/ice-9/psyntax.scm: Remove install-global-transformer.
2009-04-29 22:50:45 +02:00
Andy Wingo
3d5f3091e1 first-class macro representation (no bits on variables)
* libguile/macros.c (scm_macro_p): Update docs.

* module/ice-9/boot-9.scm (module-define!, module-ref): Define pre-boot
  forms of these functions as well. I suspect module-add! can go soon.
  (module-lookup-keyword, module-define-keyword!)
  (module-undefine-keyword!) Remove these.

* module/ice-9/psyntax-pp.scm: Regenerate. Notice the difference?

* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook): Rework to expect first-class macros. Heh
  heh.
  (remove-global-definition-hook): Pleasantly, this hook can go away.
  (chi-install-global): Terrorism to generate the right kind of output --
  will clean up.
  (chi-top): Unify definition handling for all kinds of values.
2009-04-29 21:20:28 +02:00
Andy Wingo
5a0132b337 a different tack for syncase macro representation
* libguile/macros.c (macro_print): Show syntax-case bindings, if present.
  (macro_mark): Mark the extra two words if they're there.
  (scm_make_syncase_macro, scm_make_extended_syncase_macro): OK! A new
  take at the "how do we represent syncase macros in Guile" problem.
  Whereas we need a disjoint type, but would like it to be compatible
  with old predicates (e.g. `macro?'), and need to be able to extend
  existing syntax definitions (e.g. `cond'), let's add a bit to macros to
  indicate whether they have syncase macro bindings or not, and a fourth
  macro type for native syncase macros.
  (scm_macro_type): Return 'syntax-case for native syntax-case macros.
  Note that other macro types may have syntax-case bindings.
  (scm_macro_name): Return #f if the transformer is not a procedure.
  (scm_syncase_macro_type, scm_syncase_macro_binding): New accessors for
  the syncase macro bindings.

* libguile/macros.h: Add API for syncase macros.

* module/ice-9/boot-9.scm (module-define-keyword!): Adapt to use syncase
  macros, though they are not yet used. Reorder other syncase API.

* module/ice-9/psyntax.scm (chi-expr): Fix syntax-violation invocation.
2009-04-29 00:38:12 +02:00
Andy Wingo
5f1a2fb10f syntax-dispatch -> $sc-dispatch
* module/ice-9/boot-9.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm: Change syntax-dispatch to $sc-dispatch, as it
  is in current psyntax. The idea is that this isn't really a public
  variable, though it has to be, currently, so just obscure that fact
  with an obscure name.
2009-04-26 21:10:24 +02:00
Andy Wingo
22225fc113 syntax-object->datum => syntax->datum, likewise datum->syntax
* module/ice-9/boot-9.scm (datum->syntax, syntax->datum): Rename from
  datum->syntax-object and syntax-object->datum, following r6rs. Change
  all callers. Reorder some of the other exports from psyntax.

* module/ice-9/psyntax.scm: Change datum->syntax and syntax->datum
  definitions and callers.

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

* module/oop/goops.scm (define-class-pre-definition): Update for changes.
2009-04-26 20:56:24 +02:00
Andy Wingo
e4721dde31 replace psyntax's syntax-error with r6rs' syntax-violation
* module/ice-9/boot-9.scm (syntax-violation): Well, as long as we have to
  have a function for indicating syntax errors, let's let it be a
  well-thought-out one -- syntax-violation from r6rs. No more
  syntax-error.

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

* module/ice-9/psyntax.scm: Replace instances of syntax-error with
  syntax-violation. Implement as a scm-error to 'syntax-error, with some
  nice arguments.
2009-04-26 20:36:58 +02:00
Andy Wingo
165a7596ee add module-{define-keyword!,undefine-keyword!,lookup-keyword}
* libguile/modules.c (scm_module_local_variable): Allow this to be called
  before modules are booted with #f as the module.

* module/ice-9/boot-9.scm (module-define-keyword!)
  (module-lookup-keyword, module-undefine-keyword!): Well, if syncase
  forces us to allow the keyword bindings to be partitioned from value
  bindings, let's go ahead and do that in boot-9 instead of in
  psyntax. A step on the way to removing `install-global-transformer'.
  (sc-chi): Remove.

* module/ice-9/psyntax.scm (put-global-definition-hook):
  (remove-global-definition-hook, get-global-definition-hook): Use our
  new module-* functions.
  (sc-chi): Remove, no longer needed.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-26 13:10:30 +02:00
Andy Wingo
97ce9dbf21 allow defmacros to have docstrings
* module/ice-9/boot-9.scm (define-macro, defmacro): Add the ability to
  have a docstring.

* module/ice-9/documentation.scm (object-documentation): Remove
  references to defmacro? and macro?. Since we store the transformation
  procedure as the binding, we can get docs from the procedure directly.

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

* module/ice-9/psyntax.scm (put-global-definition-hook):
  Take the type and the value separately, so we can set the variable to
  the procedure, while keeping the *sc-expander* to be the "binding
  object".
  (global-extend): Pass type and val separately.
2009-04-25 16:31:52 +02:00
Andy Wingo
0ee32d0131 allow docstrings with internal definitions
* module/Makefile.am (SCHEME_LANG_SOURCES):
* module/language/scheme/expand.scm: Remove expand.scm, we don't need it
  any more.

* module/ice-9/psyntax.scm (build-lambda, chi-lambda-clause): Support
  docstrings with internal definitions. What are Scheme people thinking
  these days?

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-24 23:56:40 +02:00
Andy Wingo
9c35c5796c make sure we compile boot code in (guile), not (guile-user)
* libguile/eval.h:
* libguile/eval.c (scm_m_eval_when): Define a cheap eval-when, used
  before syncase has booted.

* module/Makefile.am: Reorder to put (system vm) and (system repl)
  modules after the compiler, as they are not needed at runtime.

* module/ice-9/boot-9.scm: Move the eval-when earlier, to be the first
  thing -- so when we recompile Guile we do so all in the '(guile)
  module, not '(guile-user).

* module/ice-9/compile-psyntax.scm: Rewrite to assume that psyntax.scm
  will eval-when to set its module, etc. Have everything in a let --
  otherwise the `format' call is in (guile), but `target' was defined
  in (guile-user). Also, write in an eval-when to the expanded file.

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

* module/ice-9/networking.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/r4rs.scm: Sprinkles of eval-when, for flavor.
2009-04-24 23:10:31 +02:00
Andy Wingo
34ad4f83ca handle pre-module macro procedures correctly
* module/ice-9/psyntax.scm (chi-macro): It's possible for a macro
  procedure to have no module, if the procedure was made before modules
  were booted.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-24 19:59:42 +02:00