bpt/guile.git
15 years agocatch syntax errors in unquote and unquote-splicing
Andy Wingo [Thu, 21 May 2009 20:11:48 +0000 (22:11 +0200)]
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.

15 years agofix multiple values returning from srfi-18's `with-exception-handler'
Andy Wingo [Thu, 21 May 2009 19:39:37 +0000 (21:39 +0200)]
fix multiple values returning from srfi-18's `with-exception-handler'

* module/srfi/srfi-18.scm (with-exception-handler): Hah! Fixed a
  scurrilous bug in which we assumed that the thunk returned one or more
  values. Hah.

15 years agofix apply and call/cc in drop contexts
Andy Wingo [Thu, 21 May 2009 19:13:24 +0000 (21:13 +0200)]
fix apply and call/cc in drop contexts

* module/language/tree-il/compile-glil.scm (flatten): Actually apply only
  needs one arg after the proc. And shit, call/cc and apply in drop
  contexts also need to be able to return arbitrary numbers of values;
  work it by trampolining through their applicative (non-@) definitions.
  Also, simplify the single-valued drop case to avoid the
  truncate-values.

* module/language/tree-il/inline.scm (call/cc):
* module/language/tree-il/optimize.scm (*interesting-primitive-names*):
  Define call/cc as "interesting". Perhaps we should be hashing on value
  and not on variable.

* test-suite/tests/tree-il.test ("application"): Fix up test for new,
  sleeker output. (Actually the GLIL is more verbose, but the assembly is
  better.)
  ("apply", "call/cc"): Add some more tests.

15 years agoprocedures in "drop" contexts can return unspecified values
Andy Wingo [Thu, 21 May 2009 15:22:58 +0000 (17:22 +0200)]
procedures in "drop" contexts can return unspecified values

* module/language/tree-il/compile-glil.scm (flatten): For applications in
  "drop" context, allow the procedure to return unspecified values
  (including 0 values).

* test-suite/tests/tree-il.test ("application"): Adapt test.

* module/srfi/srfi-18.scm (wrap): Clarify.

* test-suite/tests/srfi-18.test: Fix so that the expression importing
  srfi-18 is expanded before the tests. However the tests are still
  failing, something about 0-valued returns...

15 years agofix srfi-17.test
Andy Wingo [Thu, 21 May 2009 14:04:14 +0000 (16:04 +0200)]
fix srfi-17.test

* test-suite/tests/srfi-17.test (exception:bad-quote): Change the
  expected exception for (set! (quote foo) ...) errors.

15 years agojust parse method arguments once.
Andy Wingo [Thu, 21 May 2009 13:34:29 +0000 (15:34 +0200)]
just parse method arguments once.

* module/oop/goops.scm (method): Tweak to just run through the arguments
  once. Thanks to Eli Barzilay for the tip.

15 years agorewrite `method' as a hygienic macro to re-allow lexical specializers
Andy Wingo [Thu, 21 May 2009 11:49:00 +0000 (13:49 +0200)]
rewrite `method' as a hygienic macro to re-allow lexical specializers

* module/oop/goops.scm (method): Reimplement as a hygienic macro. This
  seriously took me like 6 hours to figure out. Allows for lexical
  specializers: (let ((<x> ...)) (define-method (foo (arg <x>)) ...)).

* module/oop/goops/compile.scm (next-method?, compile-make-procedure):
  Remove these, as `method' does it all now, hygienically.

15 years agofix failing macro-as-parameter tests in eval.test
Andy Wingo [Wed, 20 May 2009 16:11:23 +0000 (18:11 +0200)]
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 :)

15 years agoremove compile-time-environment
Andy Wingo [Wed, 20 May 2009 15:41:21 +0000 (17:41 +0200)]
remove compile-time-environment

* module/ice-9/boot-9.scm (guile-user): Move the `compile' autoload to
  the guile-user module. Remove reference to compile-time-environment.

* module/language/scheme/compile-ghil.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/optimize.scm:
* module/system/base/compile.scm:
* test-suite/tests/compiler.test: Remove definition of and references to
  compile-time-environment. While I do think that recompilation based on
  a lexical environment can be useful, I think it needs to be implemented
  differently. So for now we've lost nothing if we take it away, as it
  doesn't work with syncase anyway.

15 years agoFix a bug in the (ice-9 match) test
Andy Wingo [Wed, 20 May 2009 15:28:59 +0000 (17:28 +0200)]
Fix a bug in the (ice-9 match) test

* testsuite/t-match.scm (matches?): Fix match invocation. As far as I can
  tell, although (ice-9 match) does advertise a => form of clauses, it
  requires that the end of the => be a symbol. For some reason this
  works in the interpreter:

    ((lambda () (begin => #t)))

  It's part of the expansion of matches?. It also worked in the old
  compiler. Thinking that maybe toplevel references could cause side
  effects, I made the new compiler actually ref =>, which brought this to
  light.

15 years agofix @slot-ref / @slot-set! compilation
Andy Wingo [Wed, 20 May 2009 11:59:42 +0000 (13:59 +0200)]
fix @slot-ref / @slot-set! compilation

* module/language/tree-il/compile-glil.scm: Add primcall compilers for
  @slot-ref and @slot-set.

* module/language/tree-il/optimize.scm (add-interesting-primitive!): New
  export. Creates an association between a variable in the current module
  and a primitive name.

* module/oop/goops.scm: Rework compiler hooks to work with tree-il and
  not ghil.

15 years agocompile `list' and `vector' to their associated opcodes
Andy Wingo [Wed, 20 May 2009 11:33:44 +0000 (13:33 +0200)]
compile `list' and `vector' to their associated opcodes

* module/language/glil/compile-assembly.scm (glil->assembly): Check the
  length when emitting calls to variable-argument stack instructions.
  Allow two-byte lengths -- allows e.g. calls to `list' with more than
  256 arguments.

* module/language/tree-il/compile-glil.scm: Add primcall associations for
  `list' and `vector', with any number of arguments. Necessary because
  syncase's quasiquote expansions will produce calls to `list' with many
  arguments.

* module/language/tree-il/optimize.scm (*interesting-primitive-names*):
  Add `list' and `vector' to the set of primitives to resolve.

15 years agodon't allocate too many locals for expansions of `or'
Andy Wingo [Wed, 20 May 2009 10:46:23 +0000 (12:46 +0200)]
don't allocate too many locals for expansions of `or'

* module/language/tree-il/analyze.scm (analyze-lexicals): Add in a hack
  to avoid allocating more locals than necessary for expansions of `or'.
  Documented in the source.

* test-suite/tests/tree-il.test: Add a test case.

15 years agoa few fixups
Andy Wingo [Wed, 20 May 2009 09:59:41 +0000 (11:59 +0200)]
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.

15 years agoand, or, cond etc use syntax-rules, compile scheme through tree-il
Andy Wingo [Wed, 20 May 2009 09:15:22 +0000 (11:15 +0200)]
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.

15 years agoadd tree-il->glil compilation test suite
Andy Wingo [Mon, 18 May 2009 21:45:35 +0000 (23:45 +0200)]
add tree-il->glil compilation test suite

* module/language/tree-il.scm (parse-tree-il): Fix a number of bugs.
  (unparse-tree-il): Apply takes rest args now.

* module/language/tree-il/analyze.scm (analyze-lexicals)
  (analyze-lexicals): Heap vars shouldn't increment the number of locals.

* module/language/tree-il/optimize.scm (resolve-primitives!): Don't
  resolve public refs to primitives, not at the moment anyway.

* test-suite/Makefile.am (SCM_TESTS): Add tree-il test.

* test-suite/lib.scm (pass-if, expect-fail, pass-if-exception)
  (expect-fail-exception): Rewrite as syntax-rules macros. In a very
  amusing turn of events, it turns out that bindings introduced by
  hygienic macros are not visible inside expansions produced by
  defmacros. This seems to be expected, so go ahead and work around the
  problem.

* test-suite/tests/srfi-31.test ("rec special form"): Expand in eval.

* test-suite/tests/syntax.test ("begin"): Do some more expanding in eval,
  though all is not yet well.

* test-suite/tests/tree-il.test: New test suite, for tree-il->glil
  compilation.

15 years agospecial cases for more types of known applications
Andy Wingo [Sun, 17 May 2009 23:08:34 +0000 (01:08 +0200)]
special cases for more types of known applications

* module/language/tree-il/compile-glil.scm (flatten): Handle a number of
  interesting applications, and fix a bug for calls in `drop' contexts.

* module/language/tree-il/inline.scm: Define expanders for apply,
  call-with-values, call-with-current-continuation, and values.

15 years agoinline calls to some primitives
Andy Wingo [Sun, 17 May 2009 21:24:26 +0000 (23:24 +0200)]
inline calls to some primitives

* module/system/base/pmatch.scm: Wrap consequents in (let () ) instead of
  (begin ) so that they can have local definitions.

* module/language/tree-il/compile-glil.scm: Inline some calls to
  primitives.

15 years agodefine `delay' in terms of make-promise
Andy Wingo [Sun, 17 May 2009 16:04:36 +0000 (18:04 +0200)]
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.

15 years agoand now, we residualize the original names into the metadata. yay!
Andy Wingo [Sun, 17 May 2009 14:46:46 +0000 (16:46 +0200)]
and now, we residualize the original names into the metadata. yay!

* module/language/tree-il/compile-glil.scm (vars->bind-list)
  (emit-bindings, flatten-lambda, flatten): Write the original names into
  <glil-bind> structures. Yaaaaay!

15 years agoactually pass original ids on to tree-il data types
Andy Wingo [Sun, 17 May 2009 14:39:55 +0000 (16:39 +0200)]
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.

15 years agopreserve original var names in lets and lambdas
Andy Wingo [Sun, 17 May 2009 14:27:18 +0000 (16:27 +0200)]
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.

15 years agotree-il -> glil compiler works now, at least in initial tests
Andy Wingo [Fri, 15 May 2009 21:44:14 +0000 (23:44 +0200)]
tree-il -> glil compiler works now, at least in initial tests

* module/language/tree-il/analyze.scm: Break analyzer out into its own
  file.

* module/language/tree-il/compile-glil.scm: Port the GHIL->GLIL compiler
  over to work on tree-il. Works, but still misses a number of important
  optimizations.

* module/language/tree-il.scm: Add <void>. Not used quite yet.

* module/language/glil.scm: Remove <glil-argument>, as it is the same as
  <glil-local> (minus an offset).

* module/language/glil/compile-assembly.scm:
* module/language/glil/decompile-assembly.scm:
* module/language/ghil/compile-glil.scm: Adapt for <glil-argument>
* removal.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Reorder, and add
  analyze.scm.

15 years agoadd lexical analyzer and allocator
Andy Wingo [Wed, 13 May 2009 22:11:25 +0000 (00:11 +0200)]
add lexical analyzer and allocator

* module/language/tree-il/optimize.scm: Rework to just export the
  optimize! procedure.

* module/language/tree-il/compile-glil.scm (analyze-lexicals): New
  function, analyzes and allocates lexical variables. Almost ready to
  compile now.
  (codegen): Dedent.

15 years agoadd primitive expander for tree-il
Andy Wingo [Tue, 12 May 2009 20:29:34 +0000 (22:29 +0200)]
add primitive expander for tree-il

* module/Makefile.am: Add inline.scm.

* module/language/tree-il.scm (pre-order!, post-order!): pre-order! is
  new. post-order! existed but was not public. They do destructive tree
  traversals of tree-il, and need more documentation. Also, add
  predicates to tree-il's export list.

* module/language/tree-il/inline.scm: New file, which expands primitives
  into more primitive primitives. In the future perhaps it will not be
  necessary, as the general inlining infrastructure will handle these
  cases, but for now it's useful.

* module/language/tree-il/optimize.scm: Move post-order! out to better
  pastures.

15 years agoadd tree-il optimizer
Andy Wingo [Mon, 11 May 2009 21:23:34 +0000 (23:23 +0200)]
add tree-il optimizer

* module/language/tree-il/optimize.scm: New module, for optimizations.
  Currently all we have is resolving some toplevel refs to primitive
  refs.

* module/Makefile.am: Add new module.

* module/language/tree-il.scm: Fix exports for accessors for `src'.

* module/language/tree-il/compile-glil.scm: Tweaks, things still aren't
  working yet.

15 years agomore work on tree-il compilation
Andy Wingo [Fri, 8 May 2009 10:56:18 +0000 (12:56 +0200)]
more work on tree-il compilation

* module/language/scheme/amatch.scm: Remove, this approach won't be used.

* module/Makefile.am: Adjust for additions and removals.

* module/language/scheme/compile-ghil.scm: Remove an vestigial debugging
  statement.

* module/language/scheme/spec.scm:
* module/language/scheme/compile-tree-il.scm:
* module/language/scheme/decompile-tree-il.scm: Add tree-il compiler and
  decompiler.

* module/language/tree-il/compile-glil.scm: Add some notes.

* module/language/tree-il/spec.scm: No need to wrap expressions in
  lambdas -- GHIL needs somewhere to put its variables, we don't.

15 years agogo ahead and regenerate psyntax-pp.scm
Andy Wingo [Thu, 7 May 2009 15:44:51 +0000 (17:44 +0200)]
go ahead and regenerate psyntax-pp.scm

15 years agoremove (ice-9 expand-support)
Andy Wingo [Thu, 7 May 2009 15:38:40 +0000 (17:38 +0200)]
remove (ice-9 expand-support)

* module/ice-9/Makefile.am:
* module/ice-9/expand-support.scm: Remove module, no longer used.

* module/ice-9/psyntax.scm: Fix a comment.

15 years agonew language: tree-il. psyntax generates it when run in compile mode.
Andy Wingo [Thu, 7 May 2009 11:45:03 +0000 (13:45 +0200)]
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.

15 years agomake expand-support structure constructors take a source argument
Andy Wingo [Thu, 7 May 2009 09:02:10 +0000 (11:02 +0200)]
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.

15 years agofix install-global construction of `define' forms
Andy Wingo [Thu, 7 May 2009 08:27:53 +0000 (10:27 +0200)]
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.

15 years agowhen compiling, use make-lexical to residualize original var names
Andy Wingo [Mon, 4 May 2009 10:18:14 +0000 (12:18 +0200)]
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.

15 years agosc-expand in compile mode produces (ice-9 expand-support) structures
Andy Wingo [Mon, 4 May 2009 09:57:36 +0000 (11:57 +0200)]
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.

15 years agoreplace sc-expand with sc-expand3, removing binding for sc-expand3
Andy Wingo [Mon, 4 May 2009 08:47:31 +0000 (10:47 +0200)]
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.

15 years agoremove (void) from boot-9 and psyntax
Andy Wingo [Wed, 29 Apr 2009 21:57:31 +0000 (23:57 +0200)]
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.

15 years agomore cleanups to boot-9/psyntax
Andy Wingo [Wed, 29 Apr 2009 21:39:09 +0000 (23:39 +0200)]
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.

15 years agoremove andmap from public API (we still have and-map)
Andy Wingo [Wed, 29 Apr 2009 21:12:12 +0000 (23:12 +0200)]
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.

15 years agocleanups to boot-9
Andy Wingo [Wed, 29 Apr 2009 20:50:45 +0000 (22:50 +0200)]
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.

15 years agofirst-class macro representation (no bits on variables)
Andy Wingo [Wed, 29 Apr 2009 19:19:23 +0000 (21:19 +0200)]
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.

15 years agoa different tack for syncase macro representation
Andy Wingo [Tue, 28 Apr 2009 22:38:12 +0000 (00:38 +0200)]
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.

15 years agosyntax-dispatch -> $sc-dispatch
Andy Wingo [Sun, 26 Apr 2009 19:10:24 +0000 (21:10 +0200)]
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.

15 years agobuild ecmascript stuff last
Andy Wingo [Sun, 26 Apr 2009 18:57:51 +0000 (20:57 +0200)]
build ecmascript stuff last

* module/Makefile.am: Wait to build ecmascript until the compiler has
  bootstrapped.

15 years agosyntax-object->datum => syntax->datum, likewise datum->syntax
Andy Wingo [Sun, 26 Apr 2009 18:56:24 +0000 (20:56 +0200)]
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.

15 years agoreplace psyntax's syntax-error with r6rs' syntax-violation
Andy Wingo [Sun, 26 Apr 2009 18:36:58 +0000 (20:36 +0200)]
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.

15 years agoadd module-{define-keyword!,undefine-keyword!,lookup-keyword}
Andy Wingo [Sun, 26 Apr 2009 11:10:30 +0000 (13:10 +0200)]
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.

15 years agoremove sc-macro definition
Andy Wingo [Sun, 26 Apr 2009 09:48:29 +0000 (11:48 +0200)]
remove sc-macro definition

* module/ice-9/boot-9.scm (sc-macro): Remove sc-macro definition, yay.

15 years agofix module-bound?, start compiling srfi-18.scm
Andy Wingo [Sun, 26 Apr 2009 09:35:23 +0000 (11:35 +0200)]
fix module-bound?, start compiling srfi-18.scm

* module/Makefile.am (SRFI_SOURCES): Let's finally start compiling
  srfi-18.scm, what the hell.

* module/ice-9/boot-9.scm (module-bound?): module-bound? was returning
  true if (not (variable-bound? (module-local-variable m v))), but
  (variable-bound? (module-variable m v)). Fix to cut out on the first
  variable it finds. This bug has been there for a while now.

15 years agoFix the elisp memoizer code for syncase-in-boot-9
Andy Wingo [Sat, 25 Apr 2009 17:09:19 +0000 (19:09 +0200)]
Fix the elisp memoizer code for syncase-in-boot-9

* lang/elisp/interface.scm:
* lang/elisp/internals/lambda.scm:
* lang/elisp/primitives/syntax.scm:
* lang/elisp/transform.scm: Use (lang elisp expand) as the transformer,
  because we really are intending this code for the memoizer and not the
  compiler.

* lang/elisp/expand.scm: A null expander.

* lang/elisp/interface.scm (use-elisp-file, use-elisp-library):
* lang/elisp/transform.scm (scheme): Turn these defmacros into
  procedure->memoizing-macro calls, given that without syncase we have no
  defmacro either.

* lang/elisp/primitives/fns.scm (macroexpand): Comment out, as Scheme's
  macro expander (temporarily on hiatus) won't work with elisp.

15 years agoallow defmacros to have docstrings
Andy Wingo [Sat, 25 Apr 2009 14:31:52 +0000 (16:31 +0200)]
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.

15 years agoall of guile compiles now, expanded with syncase
Andy Wingo [Sat, 25 Apr 2009 12:10:08 +0000 (14:10 +0200)]
all of guile compiles now, expanded with syncase

* libguile/eval.c (scm_m_eval_when): Whoops, eval-when has an implicit
  begin. Fix.

* module/oop/goops.scm: Syncase doesn't like definitions in expression
  context, and grudgingly I have decided to go along with that. But that
  doesn't mean we can't keep the old semantics, via accessing the module
  system directly. So do so. I took the opportunity to rewrite some
  macros with syntax-rules and syntax-case -- the former is nicer than
  the latter, of course.

* module/oop/goops/save.scm: Don't define within an expression.

* module/oop/goops/simple.scm (define-class): Use define-syntax.

* module/oop/goops/stklos.scm (define-class): Use define-syntax.

15 years agofix bad syntax in define-macro, (ice-9 match), and (oop goops)
Andy Wingo [Sat, 25 Apr 2009 10:50:53 +0000 (12:50 +0200)]
fix bad syntax in define-macro, (ice-9 match), and (oop goops)

* module/ice-9/boot-9.scm (define-macro): Use syntax-case to destructure
  macro arguments, so we get good errors.

* module/ice-9/match.scm (defstruct, define-const-structure): Don't
  unquote in the `defstruct' macro as a value in expansions.

* module/oop/goops.scm (standard-define-class): Can't define a macro with
  `define', use `define-syntax' instead.
  (define-accessor): Use syntax-rules. Doesn't give us much in this case.
  (toplevel-define!): New helper, to let us keep GOOPS' behavior with the
  new expander. Some solution that works lexically and at the toplevel
  would be nice, though.
  (define-method): Reimplement with syntax-rules -- soooo much nicer.

* module/oop/goops/dispatch.scm (lookup-create-cmethod): Don't define
  within an expression.

15 years agoallow docstrings with internal definitions
Andy Wingo [Fri, 24 Apr 2009 21:56:40 +0000 (23:56 +0200)]
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.

15 years agomake sure we compile boot code in (guile), not (guile-user)
Andy Wingo [Fri, 24 Apr 2009 21:10:31 +0000 (23:10 +0200)]
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.

15 years agohandle pre-module macro procedures correctly
Andy Wingo [Fri, 24 Apr 2009 17:59:42 +0000 (19:59 +0200)]
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.

15 years agoMerge branch 'master' into syncase-in-boot-9
Andy Wingo [Fri, 24 Apr 2009 17:45:43 +0000 (19:45 +0200)]
Merge branch 'master' into syncase-in-boot-9

15 years agomerge ice-9, srfi, oop makfiles into module makefile
Andy Wingo [Fri, 24 Apr 2009 17:16:06 +0000 (19:16 +0200)]
merge ice-9, srfi, oop makfiles into module makefile

* configure.in: No longer output the Makefile.ins.

* module/Makefile.am: Include the contents of ice-9/, srfi/, and oop/.

* module/ice-9/Makefile.am:
* module/ice-9/debugger/Makefile.am:
* module/ice-9/debugging/Makefile.am:
* module/oop/Makefile.am:
* module/oop/goops/Makefile.am:
* module/srfi/Makefile.am: Removed.

15 years agofinish transition to bare/hygiene/public/private
Andy Wingo [Fri, 24 Apr 2009 11:30:57 +0000 (13:30 +0200)]
finish transition to bare/hygiene/public/private

* module/ice-9/boot-9.scm (make-module-ref): Remove the transition
  support.

* module/ice-9/psyntax.scm (get-global-definition-hook): Remove
  transition support. Also remove support for guile-macro.
  (build-global-reference, build-global-assignment): Remove transition
  support.

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

15 years agoonly bend hygiene in macro-introduced output, not for explicit @/@@
Andy Wingo [Fri, 24 Apr 2009 11:13:29 +0000 (13:13 +0200)]
only bend hygiene in macro-introduced output, not for explicit @/@@

* module/ice-9/psyntax.scm
* module/ice-9/psyntax-pp.scm
* module/ice-9/boot-9.scm (make-module-ref): We were so almost there
  with what we had, sniff. The deal is that
    (begin (load "foo.scm") ((@@ (foo) bar)))
  would expand to
    (begin (load "foo.scm") (bar))
  because bar was unbound at expansion time, and make-module-ref assumed
  it was like the else in a cond. But it shouldn't have, because we
  /explicitly/ asked for the @@ var -- so now if we see a @ or @@, we
  never drop it. @@ introduced by hygiene can be dropped if it doesn't
  reference a var, though.

  Practically speaking, this means tagging all modules in psyntax with
  their intent: public or private (corresponding to @ or @@), hygiene
  (introduced by a macro), or bare (when we don't have a module). I'm
  not sure when we'd see a bare.

  The implementation is complicated by the need to support the old
  format and the new format at the same time, so that psyntax-pp can be
  regenerated.

15 years agofix @ and syncase
Andy Wingo [Fri, 24 Apr 2009 10:12:24 +0000 (12:12 +0200)]
fix @ and syncase

* module/ice-9/boot-9.scm
  (make-module-ref): equal?, not eq?, when matching on module name.
  (Module names don't have to come from an invocation of module-name in
  this process.)

* module/ice-9/psyntax.scm (build-global-reference)
  (build-global-assignment, @): Rework the format of the module in syntax
  objects so that a car of #f indicates a public reference. Loading (foo
  %module-public-interface) didn't guarantee that (foo) was loaded and
  useful.

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

* module/language/scheme/compile-ghil.scm (lookup-transformer):
  primitive-macro? does not exist any more.

15 years agoice-9 syncase now deprecated, woo
Andy Wingo [Thu, 23 Apr 2009 11:34:23 +0000 (13:34 +0200)]
ice-9 syncase now deprecated, woo

Remove #:use-module (ice-9 syncase) from lots of places, as it's no
longer needed.

15 years agoit is alive!!!!! + concision + fix to compile-ghil
Andy Wingo [Thu, 23 Apr 2009 11:30:23 +0000 (13:30 +0200)]
it is alive!!!!! + concision + fix to compile-ghil

* module/ice-9/boot-9.scm: Remove lots of debugging prints. Remove some
  already-deprecated attempts to load modules from shared libraries.

* module/ice-9/psyntax.scm: If we have to create a variable for a
  syntactic binding, initialize its contents to a gensym. I'd like
  something more meaningful, but at least this way we can tell different
  macros apart. Only warn about missing modules if modules are booted.
  Chi the value part of a (set! (@ ...) ) expression -- whoops!

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

* module/language/glil.scm (parse-glil): Fix an unquoting error.

* module/language/scheme/compile-ghil.scm: No need to import syncase, we
  gots it. Rework compiler to expand only once, with syncase, instead of
  incrementally. Fix define-scheme-transformer to work with syncase, by
  not referencing bare keywords. It works!

15 years agoallow redefinition of global macros to variables
Andy Wingo [Thu, 23 Apr 2009 10:41:03 +0000 (12:41 +0200)]
allow redefinition of global macros to variables

* module/ice-9/psyntax.scm: Allow the redefinition of keywords to
  variables. Otherwise we can't do (define let #f), which is totally
  useful and stuff.

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

15 years agofix load for syncase-in-boot-9; compile-psyntax works again
Andy Wingo [Fri, 24 Apr 2009 12:08:32 +0000 (14:08 +0200)]
fix load for syncase-in-boot-9; compile-psyntax works again

* module/ice-9/r4rs.scm:
* module/ice-9/boot-9.scm (%load-verbosely, assert-load-verbosity)
  (%load-announce, %load-hook, load): Move these from r4rs.scm to
  boot-9.scm.

* module/ice-9/compile-psyntax.scm: Update to work with
  syncase-in-boot-9.

* module/ice-9/psyntax-pp.scm: Recompiled with syncase-in-boot-9.

15 years agoleap of faith: (ice-9 syncase) in psyntax-pp.scm -> (guile)
Andy Wingo [Fri, 24 Apr 2009 12:01:26 +0000 (14:01 +0200)]
leap of faith: (ice-9 syncase) in psyntax-pp.scm -> (guile)

* module/ice-9/psyntax-pp.scm: Manually switch psyntax-pp over to (guile)
  from (ice-9 syncase). Heh heh.

15 years agosyncase early in boot-9, defmacros in terms of syntax-case -- halfway working
Andy Wingo [Fri, 24 Apr 2009 11:54:38 +0000 (13:54 +0200)]
syncase early in boot-9, defmacros in terms of syntax-case -- halfway working

* module/ice-9/boot-9.scm
  (eval-when): Remove, as syncase is going to handle this one for us.
  (sc-expand, sc-expand3, sc-chi, install-global-transformer)
  (syntax-dispatch, syntax-error, annotation?, bound-identifier=?)
  (datum->syntax-object, free-identifier=?, generate-temporaries)
  (identifier?, syntax-object->datum, void, andmap): Oh, ugly of uglies:
  add these exciting definitions to the main environment. Hopefully we
  can pull them back out soon.
  (make-module-ref, resolve-module): Stub these out, as a replacement for
  expand-support.
  (%pre-modules-transformer): Define to sc-expand, so that we are using
  syncase from the very start.
  (defmacro, define-macro): Define in terms of syntax-case.
  (macroexpand, macroexpand-1): Remove, there should be a different way
  to get at this -- though perhaps with the same name.
  (make-module): Make sc-expand the default module-transformer.
  (process-define-module): Issue a deprecation warning when using ice-9
  syncase.
  (primitive-macro?): Remove, no meaning...
  (use-syntax): Deprecate.
  (define-private, define-public, defmacro-public): Rework in terms of
  syntax-rules.

* module/ice-9/syncase.scm: Gut, as syncase is provided by core now.

15 years agomodule-name returns '(guile) during boot; psyntax tweak
Andy Wingo [Fri, 24 Apr 2009 11:50:14 +0000 (13:50 +0200)]
module-name returns '(guile) during boot; psyntax tweak

* module/ice-9/boot-9.scm (module-name): Return '(guile) before the
  module system is booted, for syncase's benefit. Defer redefinition
  until the module system is booted.

* module/ice-9/psyntax.scm (put-global-definition-hook): Only set a
  variable if it's unbound.

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

15 years agomore steps on the way to boot-time syncase
Andy Wingo [Wed, 22 Apr 2009 21:10:35 +0000 (23:10 +0200)]
more steps on the way to boot-time syncase

* module/ice-9/boot-9.scm: Define a version of module-add! for psyntax,
  before modules are booted.

* module/ice-9/psyntax.scm: Remove a warning, and rename a variable.
  Initialize a new variable to 'sc-macro, though it will have no effect.

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

15 years agoI ain't broke, but brother I'm badly bent
Andy Wingo [Thu, 23 Apr 2009 09:25:22 +0000 (11:25 +0200)]
I ain't broke, but brother I'm badly bent

* module/ice-9/expand-support.scm (strip-expansion-structures): If, when
  producing @/@@ forms, we find that an @@ variable is not bound in its
  module, just serialize the symbol. This bends hygiene, in that it can
  introduce a global (but not lexical) reference in the expanded module,
  but it seems necessary to not produce (@@ (foo) else) in forms like
  ((@@ (foo) cond) ((test then) ((@@ (foo) else) bar))).

15 years agofix erroneous #:use-syntax clausen
Andy Wingo [Wed, 22 Apr 2009 20:27:50 +0000 (22:27 +0200)]
fix erroneous #:use-syntax clausen

* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/repl.scm:
* module/system/vm/debug.scm:
* module/system/vm/trace.scm: Change #:use-syntax to #:use-module, as
  that's really what we want to do.

15 years agomove pk, peek, and warn to the beginning of boot-9
Andy Wingo [Wed, 22 Apr 2009 20:23:43 +0000 (22:23 +0200)]
move pk, peek, and warn to the beginning of boot-9

* module/ice-9/boot-9.scm (peek, pk, warn): Move these helpers up to the
  top. I like them!
  (load-compiled): Don't define within an if, syncase doesn't like that.

15 years agomodule-name before syncase is booted
Andy Wingo [Tue, 21 Apr 2009 22:17:22 +0000 (00:17 +0200)]
module-name before syncase is booted

* module/ice-9/boot-9.scm (module-name): Give psyntax a module-name
  definition, even before psyntax is booted (in a future commit).

15 years agofix begin-deprecated
Andy Wingo [Mon, 9 Mar 2009 21:01:27 +0000 (22:01 +0100)]
fix begin-deprecated

* module/ice-9/boot-9.scm (begin-deprecated): Fix to output source code,
  doh.

15 years agotweaks to boot-9
Andy Wingo [Mon, 9 Mar 2009 20:40:30 +0000 (21:40 +0100)]
tweaks to boot-9

* module/ice-9/boot-9.scm: Move the r4rs init up to the top.
  (try-module-autoload): Don't use with-fluids before it's defined.

15 years agoallow eval to be called before modules are booted
Andy Wingo [Mon, 9 Mar 2009 20:09:22 +0000 (21:09 +0100)]
allow eval to be called before modules are booted

* libguile/eval.c (scm_eval): If the module system isn't booted, assert
  not on the module argument.

15 years agocommit some tweaks to expand.scm, likely obviated by syncase though
Andy Wingo [Mon, 9 Mar 2009 19:52:45 +0000 (20:52 +0100)]
commit some tweaks to expand.scm, likely obviated by syncase though

* module/language/scheme/expand.scm (re-annotate, expand): A couple of
  speculative cases for dealing with syncase better -- but all of this
  code is likely to go.

15 years agoscm_[current_]module_transformer returns the %pre-modules-transformer, if set
Andy Wingo [Mon, 9 Mar 2009 19:49:54 +0000 (20:49 +0100)]
scm_[current_]module_transformer returns the %pre-modules-transformer, if set

* libguile/modules.c (scm_module_transformer)
  (scm_current_module_transformer): So, if the module system hasn't yet
  booted, take the current transformer from a variable named
  %pre-modules-transformer from the %pre-modules-obarray. This is a
  prequel to booting syncase early in boot-9.

15 years agomake syncase aware of (set! (@ (foo) bar) baz)
Andy Wingo [Tue, 21 Apr 2009 20:56:51 +0000 (22:56 +0200)]
make syncase aware of (set! (@ (foo) bar) baz)

* module/ice-9/psyntax.scm (set!): Handle (set! (@ (foo ..) bar) val)
  inside syncase. Heh heh heh.

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

15 years agosyncase knows about @ / @@
Andy Wingo [Tue, 21 Apr 2009 20:26:27 +0000 (22:26 +0200)]
syncase knows about @ / @@

* module/ice-9/psyntax.scm (syntax-type): Handle a new type, module-ref.
  Like external-macro, it also has a procedure as a binding.
  (chi-expr): module-ref forms -- that is to say, (@ (foo ...) bar) -- as
  expressions they are global references, but with respect to a specific
  module.
  (@, @@): Define module-ref syntax handlers.

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

* module/ice-9/syncase.scm: Mark as primitive syntax so we don't clobber
  their definitions.

The reason I'm doing things like this is so as to support (set! (@@ ...)
...) sensibly, which will be the next patch.

15 years agodistcheck fixen
Andy Wingo [Tue, 21 Apr 2009 10:41:19 +0000 (12:41 +0200)]
distcheck fixen

* examples/Makefile.am: Fix the installed guile-config invocation to set
  PKG_CONFIG_PATH.

* meta/Makefile.am (EXTRA_DIST): Dist the bin_SCRIPTS.

* meta/guile-config (pkg-config): Better error messages if pkg-config
  invocation fails.

* meta/uninstalled-env.in (PATH): Now that guile-config and guile-tools
  are not generated, make it the srcdir/meta instead of the builddir.
  (Guile itself will be picked up from libguile.)

15 years agoMerge branch 'syncase'
Andy Wingo [Mon, 20 Apr 2009 20:26:02 +0000 (22:26 +0200)]
Merge branch 'syncase'

15 years agofix guile.m4 for sitedir change
Andy Wingo [Mon, 20 Apr 2009 16:23:11 +0000 (18:23 +0200)]
fix guile.m4 for sitedir change

* meta/guile.m4

15 years agoscripts take rest args
Andy Wingo [Mon, 20 Apr 2009 16:20:01 +0000 (18:20 +0200)]
scripts take rest args

* meta/guile-tools: Instead of fixing scripts I should have been fixing
  the script runner.

* module/scripts/compile.scm:
* module/scripts/snarf-guile-m4-docs.scm: Fix to take rest args.

15 years agosome more build fixes for bugs that I introduced
Andy Wingo [Mon, 20 Apr 2009 15:42:35 +0000 (17:42 +0200)]
some more build fixes for bugs that I introduced

* meta/guile-1.8.pc.in: Include a pkgdatadir, which will map down to
  `guile-config info pkgdatadir', used in existing guile.m4 files.

* meta/guile-config: Fix guile-config info varname. Facepalm.

* meta/guile.m4: Make GUILE_SITE_DIR use the sitedir variable instead.
  Really it should use pkg-config directly, though.

15 years agofix build errors on fresh checkout
Andy Wingo [Mon, 20 Apr 2009 15:23:40 +0000 (17:23 +0200)]
fix build errors on fresh checkout

* meta/guile-tools: We can't use srfi-1, because on a fresh checkout
  the srfi-1 shlib isn't built yet. Bummer.

* meta/uninstalled-env.in: Fix up the DYLD lines for BSDen.

* module/scripts/snart-guile-m4-docs.scm: Fix expected arguments.

15 years agofix m4->texi snarfage after the guile-tools change
Andy Wingo [Mon, 20 Apr 2009 09:42:24 +0000 (11:42 +0200)]
fix m4->texi snarfage after the guile-tools change

* doc/ref/Makefile.am: Fix to work after a make clean with the recent
  guile-tools changes.

15 years agono positions when reading psyntax-pp, validation in @/@@, cleanups
Andy Wingo [Wed, 15 Apr 2009 15:02:33 +0000 (17:02 +0200)]
no positions when reading psyntax-pp, validation in @/@@, cleanups

* module/ice-9/syncase.scm (old-debug): Re-disable position recording
  when reading psyntax-pp.

* libguile/eval.c (scm_m_at, scm_m_atat): More input validation.

* libguile/debug.c (scm_procedure_module): Use scm_env_module. Remove
  extraneous docstring.

15 years agofix hygiene + modules + local macros
Andy Wingo [Tue, 7 Apr 2009 05:48:03 +0000 (22:48 -0700)]
fix hygiene + modules + local macros

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

* module/ice-9/psyntax.scm (syntax-type): Look up the type of the car of
  a form relative to its module, if it is a syntax object. Fixes hygiene
  wrt modules and private macros.

* module/ice-9/syncase.scm (sc-macro): Add a comment.

* module/system/base/pmatch.scm: The big test case: just export pmatch,
  not ppat too.

15 years agofix handling of pre-modules errors in the vm
Andy Wingo [Mon, 9 Mar 2009 19:32:05 +0000 (20:32 +0100)]
fix handling of pre-modules errors in the vm

* libguile/vm-i-system.c (toplevel-ref, toplevel-set): Correct situation
  whereby we would not throw when toplevel vars were unbound, before
  modules had booted.

15 years ago@ and @@ as primitive macros
Andy Wingo [Mon, 9 Mar 2009 20:26:44 +0000 (21:26 +0100)]
@ and @@ as primitive macros

* libguile/eval.h:
* libguile/eval.c (error_unbound_variable, error_defined_variable):
  Move these prototypes up earlier.
  (scm_m_at, scm_m_atat): New functions, provide the @ and @@
  functionality. Moved here from defmacros because they are
  "special", inasmuch as syncase doesn't really understand them in
  interpreted code.

* module/ice-9/boot-9.scm (@, @@): Don't define as defmacros, as
  defmacros have to actually return source now.

15 years agohygienic compilation
Andy Wingo [Sun, 5 Apr 2009 18:52:22 +0000 (11:52 -0700)]
hygienic compilation

* module/language/scheme/compile-ghil.scm (lookup-transformer): Recognize
  macros as initial (@ ...) or (@@ ...) forms, enabling hygienic
  compilation.

15 years agohouston, we have hygiene
Andy Wingo [Tue, 31 Mar 2009 07:00:04 +0000 (00:00 -0700)]
houston, we have hygiene

* module/ice-9/expand-support.scm (strip-expansion-structures): Enable
  @/@@ substitution.

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

* module/ice-9/psyntax.scm: Since syntax objects are quotable, make the
  module field the module name, not the module itself. Scope the operand
  of global calls appropriately. Thread modules through syntax-dispatch
  destructuring. Houston, we have hygiene.

* module/ice-9/syncase.scm: Adapt to module / module-name changes.

15 years agomore work on modules and hygiene, not finished yet, alas.
Andy Wingo [Tue, 31 Mar 2009 05:06:35 +0000 (22:06 -0700)]
more work on modules and hygiene, not finished yet, alas.

* module/ice-9/compile-psyntax.scm: No more expansion-eval-closure.

* module/ice-9/expand-support.scm (strip-expansion-structures): Only @@
  names whose module is not the current module. Actually @@ serialization
  is disabled for this commit, just to get this one in and keep things
  working.

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

* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook): Instead of going through that stupid
  getprop/putprop interface, let's just inline Guile-specific code here.
  (build-global-reference, build-global-assignment): Fix a bug where the
  module and public? were switched, which happily allowed things to
  compile. (We reintroduce a similar bug above in expand-support.)
  (lookup): Add a module argument.
  (global-extend): Adapt for put-global-definition-hook invocation.
  (syntax-type): Lookup with mod. Return mod even for lexicals and
  define-form -- why not.
  (chi-top, fluid-let-syntax, syntax, set!): Lookup with mod. Wrap with
  mod.

* module/ice-9/syncase.scm (expansion-eval-closure)
  (current-eval-closure, env->eval-closure): OK! So the idea is: module
  hygiene is syncase's business, not ours. So lose the eval-closure
  fluid. Also, eval closures are so 1990s.
  (sc-macro): But, we have to take the module from the env, sadly. In the
  future this will be different.
  Remove the rest of the eval-closure bits. Enable source reporting,
  while we're debugging.

* module/language/scheme/compile-ghil.scm (lookup-transformer): Adapt for
  eval closure fluid changes.

15 years agoeval-closure-module, here hopefully not for long
Andy Wingo [Tue, 31 Mar 2009 04:20:44 +0000 (21:20 -0700)]
eval-closure-module, here hopefully not for long

* libguile/modules.h:
* libguile/modules.c (scm_eval_closure_module): Define a
  new-yet-deprecated accessor, to ease a transition.

15 years agothread the module through syntax-case's expansion
Andy Wingo [Mon, 30 Mar 2009 00:15:25 +0000 (17:15 -0700)]
thread the module through syntax-case's expansion

* libguile/debug.h:
* libguile/debug.c (scm_procedure_module): New procedure, returns the
  module that was current when the given procedure was defined. Used by
  syncase to scope free identifiers.

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

* module/ice-9/psyntax.scm: Thread the module through the syntax
  expansion. This is harder than it would appear because in many places
  the different components of syntax objects are destructured.

* module/ice-9/syncase.scm (guile-macro): Adapt to new signature for
  syntax transformer functions.

15 years agofinish bootstrap to syntax-objects with modules
Andy Wingo [Sun, 29 Mar 2009 18:41:02 +0000 (11:41 -0700)]
finish bootstrap to syntax-objects with modules

* module/ice-9/psyntax.scm: Now that we have gone through the
  intermediate step (in which both representations of syntax-object had
  to coexist), change all callers to make-syntax-object to pass the third
  argument, and restore the define-structure definition of syntax
  objects.

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

15 years agoadd modules to syntax objects (part 1, intermediate step)
Andy Wingo [Sun, 29 Mar 2009 18:35:55 +0000 (11:35 -0700)]
add modules to syntax objects (part 1, intermediate step)

* module/ice-9/psyntax.scm (make-syntax-object): As an intermediate step
  to adding modules to syntax objects, replace the definition of
  syntax-object as a structure with an expanded-out definition that has
  (1) a constructor that takes 2 or 3 arguments, and (2) a predicate that
  works with vectors of length 3 or 4. I couldn't just redefine
  make-syntax-object, for example, because these are internal
  definitions, and we can't have duplicate bindings in a letrec.

15 years agoserialize module information into syncase's output -- getting ready for hygiene
Andy Wingo [Sun, 29 Mar 2009 17:41:27 +0000 (10:41 -0700)]
serialize module information into syncase's output -- getting ready for hygiene

* module/ice-9/Makefile.am: Replace annotate.scm with expand-support.scm.

* module/ice-9/annotate.scm: Removed; subsumed into expand-support.scm.

* module/ice-9/compile-psyntax.scm: Strip out expansion structures before
  writing to disk.

* module/ice-9/expand-support.scm: New file. Provides annotation support,
  and other compound data types for use by the expander. Currently the
  only one that is used is the toplevel reference, <module-ref>, but we
  will record lexicals this way soon.

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

* module/ice-9/psyntax.scm (build-global-reference)
  (build-global-assignment): Instead of expanding out global references
  as symbols, expand them as <module-ref> structures, with space to
  record the module that they should be scoped against. This is in
  anticipation of us actually threading the module info through the
  syntax transformation, so that we can get hygiene with respect to
  modules.

* module/ice-9/syncase.scm: Replace eval-when. Since sc-expand will give
  us something that isn't Scheme because we put the <module-ref>
  structures in it, strip that info whenever we actually do need scheme.

* module/language/scheme/compile-ghil.scm (lookup-transformer): Strip
  expansion structures here too.

* module/language/scheme/expand.scm (language): Swap annotate for
  expand-support. But this file will die soon, I think.

15 years agofix a tricky GC bug in scm_c_make_subr
Andy Wingo [Fri, 17 Apr 2009 13:18:46 +0000 (15:18 +0200)]
fix a tricky GC bug in scm_c_make_subr

* libguile/procs.c (scm_c_make_subr): Fix a really tricky bug!!! If
  scm_double_cell caused GC, the symbolic name wouldn't be marked. But
  the symptom wouldn't appear until you accessed that symbol much later,
  for example during tab completion / apropos grovelling. Not sure why we
  didn't see this earlier.

15 years agoguile-tools is a scheme script that loads scheme modules
Andy Wingo [Fri, 17 Apr 2009 09:19:42 +0000 (11:19 +0200)]
guile-tools is a scheme script that loads scheme modules

* meta/guile-tools: Changed to be a scheme script. Instead of looking for
  executables in a "scripts dir", we just look for modules in (scripts),
  and load the modules directly.

* module/Makefile.am:
* module/scripts/: Move the scripts into module/ so they can be compiled.
  Rename scripts from `foo' to `foo.scm'.

* libguile/Makefile.am: Invoke the snarf->texi code via guile-tools.

* configure.in:
* .gitignore: Update for changes.