Commit Graph

13 Commits

Author SHA1 Message Date
Veit Heller
bdaf96550f
refactor: use quasiquoting in STDLIB and go through array in quasiquote (#1135) 2021-01-21 06:20:03 +01:00
Scott Olsen
eb85906e52
Meta set fix and refactor (#1008)
* Meta: Fix hangs on calls to meta functions

This commit fixes a subtle bug whereby setting the meta of an existing
binder would cause hangs. Ultimately, this still points to an underlying
issue in our Lookup code that causes such loops, but for now this at
least fixes the hang introduced by the doc call in `core/Tuples.carp`
(see issue #842).

The primary fix seems to be related to setting the parentEnv in a case
in which we failed to do so in `Eval.hs`. Additionally, our meta setting
macros call `eval` which causes them to be evaluated *immediately after*
expansion, causing them to be evaluated in the incorrect context in the
Tuples.carp case.

Additionally:

- Refactored primitiveMetaSet and primitiveMeta to make them cleaner.
- Only set `implements` early when we're certain we won't accidentally
  overwrite the interface.
- Generalize DocStub to `MetaStub` so that it may be used for forward
  meta declarations of any kind.

* Macros: Don't eval meta-set! macros

Calling eval in the body of the meta-set! macros can cause them to be
evaluated before anticipated, possibly setting the meta on a binding in
the incorrect environment. An exemplary case of this issue existed in
`Tuples.carp` (also fixed in this commit) whereby the generated
defmodule for a tuple type called doc, which was evaluated *before* the
emitted module, resulting in overwrites of global name docs instead of
the expected module function.

We retain `evals` in macros that are more useful in the repl, such as
`print-doc`. If a user wants to evaluated one of the meta-set macros in
the REPL, they'll need to add a call to eval.

* Macros: Restore calls to eval

Turns out the meta-set! macros *do* require calls to eval, unlike I
reported in the previous commit. This commit restores those and replaces
the `doc` call in `Tuples.carp` with a direct `meta-set!` to ensure we
have docs for those functions.

Also fixed a small error in implements primitive.

* Primitives: Refactor i->inner in primitiveImplements
2020-11-24 19:27:34 +01:00
hellerve
a3dd41ee25 docs: fix typo in Quadruple docs 2020-10-15 15:16:37 +02:00
hellerve
9be2b8e4fb core: autogenerate Tuple types and document 2020-05-24 11:49:27 +02:00
scottolsen
e44f5e00c7 Fix erroneous implements call for PairRef.> 2020-05-19 16:54:36 -04:00
Scott Olsen
f13a2fdd9d Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Jorge Acereda
7b7cb5d1e5 Substitute /= interface by a generic. 2019-09-20 23:49:20 +02:00
GrayJack
783167bb27 Modify the functions Array.maximum and Array.minimum to be safe
- Also made zero function for Pair so we don't lose compatibility with
   it
2019-05-13 21:41:45 -03:00
hellerve
58e280c553 core: add Pair.reverse and Map.reverse 2019-05-05 11:49:30 +02:00
Joel Kaasinen
77a15e49d2 core/Tuples.carp: < and > for Pair and PairRef 2018-12-09 18:34:10 +02:00
Joel Kaasinen
31824bcadb Map.to-array and Set.to-array functions, equality for non-ref Pairs 2018-12-07 21:28:36 +02:00
Erik Svedäng
275947dc35 BUGFIX: Can't define '=' in terms of '=' on generic members of type, see Pair.= 2018-06-13 12:29:54 +02:00
Erik Svedäng
12dbe36adc Added function 'zip' and 'enumerated' for Array. 2018-06-01 11:18:34 +02:00