Commit Graph

1063 Commits

Author SHA1 Message Date
Scott Olsen
af1d0065e2 Index arguments from 0 in with-copy
Indexing from zero is consistent with the rest of Carp's indexing
behavior, so this should make the function more predictable. I've also
added a note to the docs about this.
2020-08-18 22:52:56 -04:00
scottolsen
3a82e7d5c0 Rename proxy->with-copy, update docs
with-copy better communicates that this macro will produce a function
that performs a copy--it doesn't cover the fact that it creates a
references to an anonymous function...but there's only so much we can
cover in a name.

I've also updated the documentation.
2020-08-10 17:59:26 -04:00
scottolsen
14a3d9b5ab Support introspection on external functions
Like the previous two commits, this commit extends support for
reflection to yet another type, externally registered functions,
allowing us to support calls such as `(arity Int.+)`.
2020-08-10 17:56:28 -04:00
scottolsen
33a7f51c7b Support introspecting primitives
Just as the prior commit added support for capturing the arity of
registered commands, this one captures the arity of registered
primitives, enabling one to make calls such as `(arity defmacro)`, etc.

I have also moved the dummy argument name function into Util.hs since
it's used in both Commands.hs and Primitives.hs.
2020-08-10 17:06:46 -04:00
scottolsen
607d0c0664 Support introspection of commands
Previously, the command xobjs did not capture the arity of their
definitions. After this commit, they do, which enables us to surface
useful information about commands in reflective modules such as
core/Introspection.

Calls such as `(arity Dynamic.+)` and `(arity Dynamic.load)` will work
after this change.
2020-08-10 15:57:55 -04:00
scottolsen
6327f51c73 Add a proxy macro for generating functions for higher-orders
It's a fairly common pattern in Carp to call a higher-order function on
some structure of values, such as an Array. However, these structures,
and their members, all have lifetimes under Carp's memory management
model, which means they expect functions that are mapped over them to
take *a reference to a value* rather than a pure value. Array.reduce is
one example of such a "referential" higher-order, the type of its
function argument is:

```
(Fn [a, (Ref b c)] a)
```

That is, this function takes some pure initial value, then expects to be
called against the members of an array, which are *references* to the
values that are alive throughout the Array's lifetime.

However, one often wants to use a function that operates on pure values
in such contexts, such as +, which forces the programmer to write
anonymous functions that handle copying referenced values to pass them
to the underlying "pure" function:

```
(Array.reduce &(fn [x y] (+ x @y)) 0 &[1 2 3])
```

So, in using some high-order function over some structure in Carp one
usually has to do two things:

1. Wrap the function in a ref
2. Handle copying references into values in order to pass them into some
   simpler function that can also be used outside of memory-bound
   contexts.

The `proxy` macro captures this pattern. It wraps a given function in a
referenced anonymous function and copies an argument of that function at
a designated position before calling the underlying function. For
example, with `proxy`, the above example becomes:

```
(Array.reduce (proxy + 2) 0 &[1 2 3])
```

The macro effectively gives a name to a common pattern--typically it
will only save the programmer a few characters, but it perhaps makes the
act of using a "function that doesn't care about references" in a
reference dominant context more apparent.

One can also use the macro to develop more specialized macros for
certain higher-orders, since these usually dictate where copying must be
performed. For instance, the `Array.reduce` function argument always
expects the referenced value to occur in the second position, thus one
could write:

```
(defmacro reducer [function] (eval (list proxy function 2)))
```

Then the above code becomes even simpler:

```
(Array.reducer (reducer +) 0 &[1 2 3])
```

Which roughly means, "use the + function (which has no concept of
references) in this reference dependent context".

N.B. The examples using `+` won't work as of now due to current bugs
related to calling `arity` directly on an interface--but a synonym for
plus `add` defined as an explicit function will make all the above work
as expected.
2020-08-07 17:12:43 -04:00
scottolsen
88dc929904 Add gensym-local dynamic function
gensym-local is similar to gensym-with, with it's arguments reversed.
That is, rather than allowing the user to specify a custom qualifier, it
allows the user to specify a custom counter (or any symbol) and appends
this to the default gensym `gensym-generated` symbol.

This enables one to, e.g. map over an array and generate symbols:

```
(map gensym-local (map Symbol.from [1 2 3]))
=> (gensym-generated1 gensym-generated2 gensym-generated3)
```

Theoretically, passing `gensym` as-is to `map` would accomplish this
using the global gensym-counter, but the counter is not incremented on
subsequent calls. This function gives users more flexibility as well.
2020-08-07 17:08:59 -04:00
Erik Svedäng
5f8e9318b2
Merge pull request #906 from hellerve/veit/string-from-bytes
Add String.from-bytes
2020-07-13 14:09:07 +02:00
Erik Svedäng
027a189c1e
Merge pull request #905 from hellerve/veit/bit-interfaces
make bit-* interfaces
2020-07-13 14:08:41 +02:00
Erik Svedäng
0a2a2d257f
Merge pull request #894 from jacereda/addc
Added add-c to include additional compilation units in the compiler i…
2020-07-13 14:07:53 +02:00
hellerve
3b8b668bdf core: fix syntax error 2020-07-08 22:00:43 +02:00
hellerve
57a5226a62 core: make sure string is null-terminated in String.from-bytes 2020-07-08 21:56:15 +02:00
hellerve
91b220c051 core: add String.from-bytes 2020-07-08 21:56:14 +02:00
hellerve
06607c2203 core: make bit-* interfaces 2020-07-08 21:11:28 +02:00
Erik Svedäng
28873e92d0
Merge pull request #896 from hellerve/veit/unreachable
Add unreachable
2020-07-03 09:42:14 +02:00
Jorge Acereda
d6aa71702e Add header/lib for OpenGL on each platform. 2020-06-29 11:57:06 +02:00
Jorge Acereda
134d9a5b02 Implement load-stack. 2020-06-28 19:53:43 +02:00
Jorge Acereda
0d7533e887 Register additional modules in project. 2020-06-27 21:48:46 +02:00
hellerve
43951a4c9f core: use abort in unreachable 2020-06-26 18:57:06 +02:00
hellerve
fb3ef6a47f core: add Bool.zero 2020-06-23 12:26:53 +02:00
hellerve
a96f774bc5 core: add unreachable 2020-06-23 12:19:14 +02:00
Erik Svedäng
73bb5735c1
Merge pull request #893 from scolsen/private
Implement Privacy Checking
2020-06-22 20:51:08 +02:00
Jorge Acereda
e6cf941187 Added add-c to include additional compilation units in the compiler invocation. 2020-06-21 17:22:24 +02:00
scottolsen
b94b49bf86 Implement private
Even though `private?` has been around for a while, and we document the
behavior of `private` as marking a binding as private to a module--it
was never implemented as far as I can tell.

This implements private by adding a simple check to the evaluator. If a
binding is found in the global context, we check if it's marked as
private. If so, we inform the user that it can't be called from outside
of its module.

Note that we don't perform this check if the binding is found in the
internal env, since that means it's a function called within the same
module and thus is ok (even if marked as private).

After this change, something like the following works, granting us
proper encapsulation:

```
;; File Foo.carp
(deftype Foo [bar Int])

(private Foo.bar)

(defmodule Foo
  (defn get [foo]
    (Foo.bar foo))
)

;; Enter REPL
(load "Foo.carp")
(Foo.bar &(Foo.init 1))
The binding: Foo.bar is private; it may only be used within the module
that defines it. at REPL:1:2.
@(Foo.get &(Foo.init 1))
Compiled to 'out/Untitled' (executable)
1
=> 0
```

N.B. I also had to remove a private declaration from fmt-internal--this
declaration didn't really make much sense anyway, as fmt-internal is a
global function, so module-based privacy is not enforceable.
2020-06-19 10:30:55 -04:00
scottolsen
da3be90b55 Merge branch 'master' of https://github.com/carp-lang/Carp into opaque 2020-06-19 09:18:34 -04:00
Erik Svedäng
15bdf38f23
Merge pull request #888 from hellerve/veit/phantoms
core: add Phantom
2020-06-19 09:30:42 +02:00
Basile Pesin
3b258badce Added some of GLFW constants 2020-06-18 23:19:31 +02:00
scottolsen
b63f981575 Update Opaque docs; fix typos 2020-06-18 09:57:28 -04:00
scottolsen
204ebc85e4 Load the Opaque type 2020-06-17 18:16:58 -04:00
scottolsen
b3a5ab8622 Add the Opaque type
The opaque type is an uninhabited type with no constructors.  Opaque can
be used to force some abstract type to range over a type constructor
without concerning oneself with the inhabitant of the constructor--in
other words, it may be used to enable a type to work for all inhabitants
and can express relationships between types. It can facillitate generic
programming.

Consider an example:

```
;; The type of indicies over containers of a single type argument
(deftype (Index (f Opaque) b) [at b])

(definterface tabulate (Fn [(Ref (Fn [(Index (f Opaque) b)] c))] (f c)))
(definterface positions (f (Index (f Opaque) b)))

(implements tabulate tabulate)
(defn tabulate [h]
  (fmap h @&positions))

(deftype (Tuple a) [x a y a])

(defmodule Tuple
  (sig positions (Tuple (Index (Tuple Opaque) Bool)))
  (def positions (Tuple.init (Index.init true) (Index.init false)))
)
```

In the above example, the Opaque type allows us to define tabulate
generically defined over Tuples without having to ensure their
inhabitants match, allowing us to fully determine the resulting values
type via tabulate's function argument. Without Opaque, Index would
contain a generic type which would be unreseolved upon the call to
`tabulate`. It allows us to ensure the `positions` we call are the
positions of the correct constructor type `f` wihtout worrying having to
restrict ourselves to only calling `Indexes` over an `f` of a specific
type  (e.g. `(f a)`)--in other words, it allows us to constrain
functions by constructor types only.

Thanks to Opaque, tabulate can generate an `(Array Int)`, `(Array
Bool)`, `(Array String)` all solely dependent on the return type of `h`.
2020-06-17 18:14:23 -04:00
hellerve
1d0944a187 core: add docs for phantom 2020-06-17 19:06:49 +02:00
hellerve
e5fd0e73f9 core: add phantom 2020-06-14 12:16:45 +02:00
Jorge Acereda
6656d96791 Add pkgconfigflags. 2020-06-01 21:34:12 +02:00
Jorge Acereda
5db1f0101f Remove braces so different clang-formats output the same. 2020-05-30 09:32:50 +02:00
Jorge Acereda
543a90ffa0 Add joinLines. 2020-05-30 09:19:26 +02:00
scottolsen
383f400a32 Fix length checks, use or 2020-05-27 15:22:42 -04:00
scottolsen
095866e45f Add length checks to struct? and sumtype? for safety 2020-05-27 15:03:10 -04:00
scottolsen
b0d9a34375 Update Introspect to work with the s-expr command 2020-05-27 13:33:43 -04:00
hellerve
357d28a167 core: update doc of cond 2020-05-26 21:50:26 +02:00
Erik Svedäng
bbb7920332
Merge pull request #815 from hellerve/veit/fix-776
Make Array.range safe
2020-05-26 20:55:16 +02:00
Erik Svedäng
bf4fed793a
Merge pull request #833 from hellerve/veit/fix-830
Autogenerate Tuple types and document
2020-05-26 20:51:46 +02:00
Scott Olsen
9b9aa76b59 Improve introspection support for interfaces
Previously, introspecting an interface only returned `definterface` and
its name. We now return the form corresponding to the interface's types
signature, which enables us to introspect more effectively; e.g.
returning the appropriate arity of an interface.
2020-05-24 17:02:35 -04:00
hellerve
229264f7d1 core: update dcostring for range-or-default 2020-05-24 12:51:11 +02:00
hellerve
be8424657d core: rename unsafe-range to range-or-default 2020-05-24 12:26:18 +02:00
hellerve
9be2b8e4fb core: autogenerate Tuple types and document 2020-05-24 11:49:27 +02:00
Erik Svedäng
ea372b1728
Merge pull request #827 from jacereda/cmdline-eval
Command line switches to evaluate code
2020-05-24 11:45:44 +02:00
Scott Olsen
4a29c6a998 Rename s-exp -> s-expr 2020-05-23 15:42:32 -04:00
Jorge Acereda
b681cf2644 Detect __builtin_x_overflow() based on __GNUC__ macro. 2020-05-23 19:03:07 +02:00
Scott Olsen
d45a6424eb Fix arity for sumtypes 2020-05-22 01:29:53 -04:00
Scott Olsen
7f095d754c Add Introspect module
The introspect module contains functions that return information about
program bindings based on their s-expressions.
2020-05-22 01:16:55 -04:00
Jorge Acereda
ccb31c589a Avoid division by zero. 2020-05-21 20:05:02 +02:00
Jorge Acereda
59ef5bbf2b Added --compile-fast to compile with tcc. 2020-05-21 20:04:54 +02:00
hellerve
74d734903e core: move range into array ext and add unsafe-range 2020-05-21 15:23:29 +02:00
scottolsen
f819f083cc Fix signature of Control.iterate-until
Now that sigs work, turns out the signature for iterate-until and it's
definition don't match.

There was an extra argument in the sig, which I've removed. Adding a ref
to `result` also confused the type checker, since result technically has
two types in the definition whenever `b` is not a ref. I believe the
side effect of this change is that the `start` argument must now be a
`Ref`, but at least it's well-typed.
2020-05-20 23:40:46 -04:00
Erik Svedäng
099d242d1f
Merge pull request #820 from hellerve/veit/fix-818
macros: fix hidden?, private?, and annotate?
2020-05-20 22:32:32 +02:00
hellerve
cc19bdc917 macros: fix hidden?, private?, and annotate? 2020-05-20 10:04:05 +02:00
scottolsen
e44f5e00c7 Fix erroneous implements call for PairRef.> 2020-05-19 16:54:36 -04:00
scottolsen
39e9836452 Add an implements? macro
This macro simply returns true or false if a binding implements a given
interface.
2020-05-19 16:53:15 -04:00
Erik Svedäng
74c5542abb
Merge pull request #816 from hellerve/veit/add-implements-to-longref
Add missing longref implements annotations
2020-05-19 06:11:14 +02:00
hellerve
32d4095a5d core: make NULL Ptr a instead of a 2020-05-18 23:21:16 +02:00
hellerve
5f408229a1 core: add missing longref implements procs 2020-05-18 23:02:26 +02:00
hellerve
3353427dd9 core: make Array.range safe 2020-05-18 22:59:41 +02:00
Erik Svedäng
d85086e518
Merge pull request #810 from hellerve/veit/fix-debug-trace
Fix Debug.trace for new evaluator
2020-05-18 20:51:00 +02:00
hellerve
1b39139d7b core: fix Debug.trace for new evaluator 2020-05-16 12:46:05 +02:00
Scott Olsen
5cd786c732 Add an implements-all macro
This macro adds implements forms for functions with the same name as a
given list of interfaces in a given module.
2020-05-15 12:46:35 -04:00
Erik Svedäng
f71613a0c8
Merge pull request #796 from dbalan/freebsd_platform
Add FreeBSD as a supported platform
2020-05-13 21:25:20 +02:00
Erik Svedäng
14a0d7e722
Merge pull request #799 from hellerve/veit/string-to-bytes
Add String.to-bytes
2020-05-13 20:59:37 +02:00
Erik Svedäng
855ddb75bf
Merge pull request #798 from hellerve/veit/generics-typo-fix
Fix typo in docs for Generics.approx
2020-05-13 20:59:04 +02:00
hellerve
468c232741 core: add String.to-bytes 2020-05-13 17:15:26 +02:00
hellerve
8e062c3173 core: fix typo in docs for Generis.approx 2020-05-13 16:45:11 +02:00
Dhananjay Balan
05bf39827b Add signal.h on FreeBSD platforms
The SIGNAL definitions are in signal.h, this also adds a macro freebsd-only, in the style of other platform-only macros.
2020-05-13 16:10:00 +02:00
Erik Svedäng
e4e3c4208a
Merge pull request #790 from hellerve/veit/safe-num-from-string
Make Num.from-string better
2020-05-12 23:04:00 +02:00
hellerve
058ef11f9c core: add implements for FloatRef comparators 2020-05-12 22:45:29 +02:00
hellerve
c569666a0a core: make from-string better 2020-05-12 22:33:40 +02:00
Erik Svedäng
d9295b3c1f
Merge pull request #788 from hellerve/veit/str-on-numeric-refs
Add str on refs for numeric types
2020-05-12 22:25:25 +02:00
Erik Svedäng
dcca7505d1
Merge pull request #786 from hellerve/veit/move-to-templates
Move templates out of the compiler into deftemplates
2020-05-12 22:24:54 +02:00
hellerve
fe2c08c1ff core: rearrange templates 2020-05-12 21:58:40 +02:00
hellerve
eec1ad9375 test: rollback accidently commited test update 2020-05-12 21:54:48 +02:00
hellerve
06f7ea4c28 docs: update for refs 2020-05-12 21:50:21 +02:00
hellerve
8636dd467f core: add str on refs for numeric types 2020-05-12 21:50:20 +02:00
Erik Svedäng
aae743fb35
Merge pull request #769 from scolsen/implement-prim
Add an `implements` primitive, update core
2020-05-12 21:45:29 +02:00
Erik Svedäng
2121b87151
Merge pull request #787 from hellerve/veit/add-new-asserts
Add assert-ref-equal, assert-just, and assert-nothing
2020-05-12 19:59:36 +02:00
hellerve
9e2c2fe2fd test: add assert-ref-equal, assert-just, and assert-nothing 2020-05-12 14:53:42 +02:00
hellerve
fce423aee9 core: move as many templates as possible out of the compiler 2020-05-12 12:44:17 +02:00
Erik Svedäng
9ba6a26ff1
Merge pull request #782 from TimDeve/enumerate-empty-arrays
Makes enumerated work with empty arrays
2020-05-12 12:03:14 +02:00
Erik Svedäng
0f461dd011
Merge pull request #771 from hellerve/veit/pattern-substitute-docs
Mention backreferences in docs for Pattern.substitute
2020-05-12 11:33:17 +02:00
hellerve
d2235112dd core: move the first function into carp template 2020-05-12 11:32:26 +02:00
Jorge Acereda
2186b34e94 Roll our own UTF-8 support. 2020-05-12 01:14:02 +02:00
Jorge Acereda
4e744a00ae Don't include windows.h on mingw. 2020-05-12 01:13:36 +02:00
Tim Deve
8fc5ce2946 Removes usage of range in enumerated
`range` signature is likely to change in the future
this change gets ahead of that but using a more
'procedural' style.
2020-05-11 19:55:09 +01:00
scottolsen
681054be63 Merge branch 'master' of https://github.com/carp-lang/Carp into implement-prim 2020-05-11 14:42:11 -04:00
Tim Deve
58ab18da46 Makes enumerated work with empty arrays
This is a work around for https://github.com/carp-lang/Carp/issues/776
the proper fix would be to allow range to take `(range 0 0 1)` inputs
but the decision about what the correct behavior should be hasn't been
made.
2020-05-11 16:37:07 +01:00
Jorge Acereda
a95fe95ab1 Fix warning on Windows. 2020-05-11 16:10:41 +02:00
Jorge Acereda
9b08b6df3c Merge 2020-05-11 16:10:35 +02:00
Jorge Acereda
83e8c1a874 Fix Char_str(). 2020-05-11 16:08:40 +02:00
Jorge Acereda
0fb9f9a56e Hopefully portable and simple get-line. 2020-05-11 16:08:40 +02:00
Jorge Acereda
4fb5a1195d Fix warning due to ignored fread() return value. 2020-05-11 16:08:40 +02:00
Jorge Acereda
9f87d17561 Ignoring system() return value produces warnings on some systems, just return it. 2020-05-11 16:08:40 +02:00
Jorge Acereda
de89be2bb5 Use system-include like the rest. 2020-05-11 16:08:40 +02:00
Nils 'Linkie Pi' Reid
43c64d5ed1 Fix the inline-c macro to avoid using a reserved keyword as parameter. 2020-05-11 10:58:24 +02:00
Scott Olsen
26131f2b1c Add remaining implements declarations 2020-05-10 22:53:35 -04:00
Scott Olsen
f13a2fdd9d Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
hellerve
57be1e7f4e core: mention backreferences in substitute docs 2020-05-10 12:20:26 +02:00
scottolsen
040e9e4391 Add an implements primitive, update core
This change adds a new primitive Implements which changes interface
implementations from being implicit to being explicit. Going forward,
users will have to declare (implements <interface> <implementation>) to
explicitly add a function to an interface. This provides two benefits:

- Prevents unwitting name clashes. Previously, if one defined a function
  that happened to have the same name as an interface, it was
  automatically assumed the function implemented that interface when this
  is not always the intention, especially in large programs.
- Name flexibility. One can now implement an interface with a function
  that has a different name than the interface, which allows for greater
  flexibility.

I've updated core to make the necessary calls to the new primitive.

Since str and copy are derived automatically for types, we treat these
functions as a special case and auto-implement the interfaces.
2020-05-09 12:59:47 -04:00
Nils 'Linkie Pi' Reid
a8032f3b72 Readded inline-c as a macro of deftemplate. 2020-05-08 15:17:34 +02:00
Erik Svedäng
e13048687e Remove test log. 2020-05-06 10:56:11 +02:00
Erik Svedäng
12ec75ba8b Can configure 'force-reload' that makes 'load-once' work just like 'load'. 2020-05-06 10:27:10 +02:00
Erik Svedäng
870d549da9 Merge branch 'master' into do-not-reload-core-libs 2020-05-06 10:08:56 +02:00
Erik Svedäng
78f85d73c1
Merge pull request #747 from hellerve/veit/better-dynamic-tests
Better dynamic tests
2020-05-05 15:20:08 +02:00
hellerve
4e711a4eb0 core: add docs for any? and all? 2020-05-05 15:19:43 +02:00
hellerve
80d1086cb7 tests: better dynamic tests 2020-05-05 15:09:18 +02:00
Erik Svedäng
ca804beace Added support for (load-once). 2020-05-05 15:00:57 +02:00
Erik Svedäng
6f70dbd18e Merge branch 'master' into match-on-refs 2020-05-05 13:57:58 +02:00
Erik Svedäng
9951468a5a
Merge pull request #742 from hellerve/veit/fix-719
Make primitives proper AST objects
2020-05-05 09:45:00 +02:00
hellerve
5838136f83 core: rename dynor and dynand and check in docs 2020-05-04 23:47:06 +02:00
Erik Svedäng
e6c119d34c Remove comment. 2020-05-04 13:21:40 +02:00
Tim Dévé
da98a770be Adds StaticArray nth & contains? 2020-05-04 09:35:39 +01:00
Tim Dévé
acc5dbb914 Adds StaticArray sum, index-of, element-count, predicate-count, aupdate! & swap! 2020-05-04 09:35:39 +01:00
Tim Dévé
5965b098bb Adds StaticArray reverse! 2020-05-04 09:35:39 +01:00
Tim Dévé
b5d363c85e Adds StaticArray minimum & maximum 2020-05-04 09:35:39 +01:00
Tim Dévé
27ce300648 Adds StaticArray first, unsafe-first, last & unsafe-last 2020-05-04 09:35:39 +01:00
Tim Dévé
b87fd0911c Adds StaticArray find & find-index 2020-05-04 09:35:39 +01:00
Tim Dévé
ce3f53518f Adds StaticArray empty? any? & all? 2020-05-04 09:35:39 +01:00
Tim Deve
85abcbbf0a Adds Array.from-static function 2020-05-04 09:35:37 +01:00
Tim Dévé
3222e5cd22 Adds tests for ArrayStatic map! and reduce 2020-05-04 09:30:45 +01:00
hellerve
a761b561e3 all: use dynor and dynand 2020-05-01 12:50:31 +02:00
Erik Svedäng
504f63ffb4 Merge branch 'zero-sumtypes' of https://github.com/hellerve/Carp into hellerve-zero-sumtypes 2020-04-30 14:46:35 +02:00
hellerve
7eaa30d663 core: remove result.zero 2020-04-30 14:40:01 +02:00
hellerve
918c893189 core: implement zero for Maybe and Result 2020-04-30 14:22:06 +02:00
Erik Svedäng
8e04cb476e Renamed Dynamic.String.join and Dynamic.Symbol.join to concat. 2020-04-30 13:32:54 +02:00
hellerve
a06c1dc91c core: change maybe and result to match on refs if possible 2020-04-30 12:57:27 +02:00
Erik Svedäng
89dcad4e79 Merge branch 'master' into static-arrays 2020-04-29 10:39:44 +02:00
Erik Svedäng
979077b388 Some cleanup and start of tests for Static Array. 2020-04-29 10:39:15 +02:00
Erik Svedäng
c42ffec862 Ref result. 2020-04-29 09:48:37 +02:00
Erik Svedäng
de8104eb14 Add Control.iterate-until. 2020-04-28 14:48:39 +02:00
Erik Svedäng
14b608a36e Static array kinda works now. 2020-04-28 10:06:17 +02:00
Erik Svedäng
2d295ad52f Merge branch 'master' of https://github.com/carp-lang/Carp 2020-04-26 22:05:33 +02:00
Erik Svedäng
b2c77fc19a Revert format specifier. 2020-04-26 22:05:13 +02:00
Erik Svedäng
94ed7f0696
Merge pull request #728 from scolsen/macro-fixes
Dynamic.Curry fix and Macro Tests
2020-04-24 23:20:36 +02:00
Erik Svedäng
dbc4a86f3c Use other format specifers on Windows. 2020-04-24 23:01:53 +02:00
scottolsen
ac87e8fbdc Add tests for dynamic functions
I accidentally broke `curry`, what better incentive for writing some
tests than preventing my own future silly mistakes :)

I also added and-internal because we cannot perform direct comparisons
on lists--so, instead we build member-wise comparisons by zipping, then
reduce the result using and.
2020-04-24 17:00:30 -04:00
Erik Svedäng
3093702c54
Merge pull request #726 from hellerve/veit/longs
Long type to ensure longs are actually 64 bits
2020-04-24 22:50:49 +02:00
scottolsen
3cbe0e8c79 Fix dynamic curry regression
I accidentally committed a change to the definition of curry that
severly alters how it functions! This commit fixed that, and adds a test
so that I don't unwittingly break it again :)
2020-04-24 15:38:22 -04:00
hellerve
38af3d344a safe arithmetic: disable on windows 2020-04-24 10:28:00 +02:00
hellerve
30ed0ae8c3 all: various long fixes 2020-04-23 21:50:30 +02:00
hellerve
c0ba8c723a binary: try to fix on windows 2020-04-22 10:56:53 +02:00
Jorge Acereda
a6055eec5f Long type to ensure longs are actually 64 bits. 2020-04-22 10:40:06 +02:00
Scott Olsen
4c8726808d Fix order of append in filter, quote in curry*
Originally, curry* required double quoting function arguments in some
cases, due to an eval and lack of quotes in the function body it
produces. This is not ideal, as having to type ''(form) is quite
esoteric. Now we handle the extra quoting in the function itself, so
that only one quote is required.

I also fixed the order of filter (which was reversing results).
2020-04-21 23:09:25 -04:00
scottolsen
338b1624b2 Add several utility functions to Macros.carp
This commit adds several dynamic utility functions in the spirit of map,
zip, et al, including:

- Compose (composer for functions of any airty, that evaluate
  immediately (unlike comp)
- empty (returns the empty value for a structure [] or ())
- unreduce (builds a list of values)
- filter (filters a list of values)
- take (returns the first x members of a list)

I also removed a quote in collect-into that's no longer necessary after
the evaluator refactor.
2020-04-21 19:03:53 -04:00
scottolsen
2fd7a1fe40 Restrict map to mapping only (not zipping)
We currently define two dynamic functions, map and zip. Each performs
the traditional operation given by these names, however, map, emulated
clojure's map, which would selectively apply map or zip depending on the
number of lists passed as arguments. This change removes that selection,
making the execution of map more predicatable.
2020-04-21 09:41:42 -04:00