~technomancy/fennel

Change the fennelview table reference notation to use @.
Merge branch 'fennelview-references' into main
Fix issue #325 with Fennelview
Fix a bug where function arguments would get reordered for long arglists.
Merge branch 'plugin2' into main

# Conflicts:
#	changelog.md
#	src/fennel/specials.fnl
#	src/launcher.fnl
Merge branch 'compiler-env' into main.
This patch adds support for sandboxing the compiler.

Previously there was no way to safely accept arbitrary
input since sandboxing would only apply to the compiled code, not to
macros and eval-compiler.

However, suddenly disallowing access to globals in compiler scope
would be a breaking change, so instead what we're doing is allowing
unsafe things thru but emitting a warning. In the future once we can
make a breaking change, (maybe for 1.0?) that warning will be changed
to an error.

The most awkward part about this change is its effect on require. We
want to allow modules to be loaded, but using a separate
compiler-scoped replacement for package.loaded which only allows
modules which have been loaded with the limited environment.

We have to allow `require` because of a quirk in how we compile
metadata; the compiled code requires the fennel module and sets the
docstring on the metadata field of it. So we have to allow requiring
the Fennel module. In the default compiler-env we replace require with
a new version which lets thru the module as needed for docstrings.

The sandboxing can be disabled by launching Fennel with the
flag --no-compiler-sandbox or (if you're using the compiler API) by
passing in :compiler-env _G in the options table.
Handle Fedora Lua's different error truncation behavior

One of the Fennel core tests intentionally throws an error and tries
to match it against an expected value.

This breaks on Fedora's `lua` (but works with `luajit`) since the
truncation behavior is different.

Tighten up the match so it passes on both `lua` and `luajit`.

```
  fennel on  master
  ❯ lua test/init.lua | grep -E "not ok|#  "
  not ok 9        test-core
  #   test/core.fnl:49: (fn b [] (each [e {}] (e))) (let [(_ e) (pcall b)] (e:match ":1.*"))
  #   expected: ":1: attempt to call a table value"
  #   actual: ':1.*"))"]:1: attempt to call a table value'

  fennel on  master
  ❯ luajit test/init.lua | grep -E "not ok|#  "

  fennel on  master
  ❯ rpm -q lua luajit
  lua-5.3.5-7.fc32.x86_64
  luajit-2.1.0-0.17beta3.fc32.x86_64
```

```
  fennel on  fix-tests-for-fedora-lua took 14s
  ❯ lua test/init.lua | grep -E "not ok|#  "

  fennel on  fix-tests-for-fedora-lua
  ❯ luajit test/init.lua | grep -E "not ok|#  "
```

Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
Add plugin system, take 2.

This is roughly the same as the previous take on the plugin system,
which was based on the pre-self-hosted compiler.

Each plugin is a module which contains functions for various extension
points within the compiler. Each field in the module is named after an
extension point and should be a function that takes AST arguments and
a scope table. Current supported extension points are:

* symbol-to-expression
* call
* destructure
* do
* fn

These were chosen because they're the minimum needed to implement the
linting example, not by looking thru the whole compiler to find an
exhaustive list of good extension points. So we are likely to be
missing some good candidates for extension; we should be open to
adding new ones.

The included linter.fnl file shows an example of how the system works.

However, the problem here is that we are exposing compiler internals,
and that means that when we change the internals, we are likely to
break plugins when we refactor the compiler. I don't really know what
to do about that, and it seems inevitable. So we should probably just
try to set expectations that plugins will tend to be only compatible
with a limited set of compiler versions.

One problem is that the plugins need to be loaded in compiler scope,
which means we need a way to indicate in fennel.dofile that we
want to load the file in question in the compiler scope. In this patch
you can pass :env :_COMPILER as a special flag which causes the :env
to get replaced by a new compiler-scope environment. I don't love
this; I think we could come up with a better way to expose it.

We still need more documentation for this in api.md before the release.
Fix a bug where root didn't get reset properly.
Add rationale document.
Fix a bug where method calls had args in the wrong order.
Provide a better error message when attempting to load a directory as source.
Fix a bug in the repl when providing an env.
Add brief explanation for each compiler module.
Refactor fn and if to remove var/set.
Expose list? and sym? in compiler API.
Next