Commit Graph

823 Commits

Author SHA1 Message Date
Erik Svedäng
b2c77fc19a Revert format specifier. 2020-04-26 22:05:13 +02:00
Erik Svedäng
dbc4a86f3c Use other format specifers on Windows. 2020-04-24 23:01:53 +02: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
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
Scott Olsen
ba0bfe7ed7 Return length comparison directly in empty? 2020-04-19 12:07:06 -04:00
Scott Olsen
0c512c5eaf Use append in apply
No need for extra functions :)
2020-04-19 12:04:26 -04:00
Scott Olsen
d1155aaed8 Make internal functions hidden 2020-04-19 12:00:54 -04:00
Scott Olsen
b2bb8d0e71 Add docs for zip 2020-04-19 11:57:30 -04:00
Scott Olsen
e10575e9f4 Add docs on curry and flip 2020-04-19 11:43:10 -04:00
Scott Olsen
8e027d0688 Add additional functions, restore or-internal
We need or-internal because Dynamic.or is currently a special form;
special forms can't be passed to higher-order functions like `reduce`.
2020-04-19 11:36:33 -04:00
Scott Olsen
5aa19ff8c2 Remove redundant definitions of or, and
The `or` and `and` macros suffice to do the job of `or-internal` and
`and-internal` now that we can call macros within Dynamic code
effectively.
2020-04-19 10:55:56 -04:00
Scott Olsen
54a3101654 Merge branch 'master' of https://github.com/carp-lang/Carp into dynamic-map 2020-04-19 10:34:42 -04:00
hellerve
15522206e9 macros: make save-docs eval 2020-04-17 12:59:22 +02:00
hellerve
a52c02be29 eval rewrite: rebase changes 2020-04-17 12:29:21 +02:00
hellerve
7c7bb71584 eval: final rewrite version 2020-04-17 11:58:28 +02:00
hellerve
22c53406a3 all: fixes for new evaluator 2020-04-17 11:58:28 +02:00
hellerve
e2b52655ef eval: initial working rewrite 2020-04-17 11:58:28 +02:00
hellerve
c3358ed4c5 interim 2020-04-17 11:58:28 +02:00
hellerve
6185099044 interim 2020-04-17 11:58:26 +02:00
hellerve
25732af8f0 interim 2020-04-17 11:56:05 +02:00
hellerve
ca5cc8abeb eval: add eval primitive 2020-04-17 11:56:04 +02:00
Erik Svedäng
e47b9cf580 Friendly tip. 2020-04-06 09:38:13 +02:00
Erik Svedäng
b6d4d41f46 Some fixes for SDL on Windows. 2020-04-06 09:28:50 +02:00
Tim Deve
f2f3ea57c3 Doesn't compile assert-exit and assert-signal on Windows
These two assertions expect a *nix environment
and cause a compilation failure on windows

Creates stub implementation on Windows
2020-04-03 22:07:38 +01:00
Tim Deve
11e0eb5f56 Fixes wrongly named doc for assert-signal 2020-04-03 21:24:45 +01:00
Erik Svedäng
41b450873e Carp init globals function call. 2020-03-23 10:31:58 +01:00
scottolsen
a66a5126e6 Move Byte Order type outside of the Binary module
Issue #698 points out an bug related to reloading. The illustious
hellerve@ has discovered that the issue relates to types defined in
modules--for some reason, upon reloading, the type's delete, copy, etc.
functions are doubly defined, resulting in too high or a number of
functions for Carp to work out the dependencies.
2020-03-20 19:02:55 -04:00
hellerve
1cfd873b78 core: reformat carp_binary.h 2020-02-21 13:22:01 +01:00
Erik Svedäng
608634e471
Merge pull request #690 from hellerve/veit/stdint-print
Using formatting macros for stdint
2020-02-21 13:00:10 +01:00
hellerve
238365bcc2 core: fix #688 by using the correct formatting macros\n\n(and pray that windows does c99) 2020-02-21 12:28:34 +01:00
Scott Olsen
32b61fbced Add zero for other StdInt types 2020-02-20 23:39:25 -05:00
Scott Olsen
7c7a65c43e Refactor bytes->int-seq, add exact variants
Instead of returning an array of Maybe UintNs, we now return a pair
comprised of the array of interpreted int values and the number of bytes
that were'nt read/interpreted.

We also provide an `exact` variant of this function that returns a
Result instead of a Pair. If there are excess bytes in the sequence one
attempts to interpret, the `exact` functions return a `Result.Error`
containing the number of extra bytes. If the byte sequence is exact , a
`Success` containing the interpreted values is returned instead.
2020-02-20 14:12:38 -05:00
Scott Olsen
03d93f7b65 Add zero values for unsigned int types 2020-02-20 14:12:14 -05:00
Scott Olsen
edee6d9dc9 Add basic tests for the binary module
I've also added the Binary module to Core.carp.
2020-02-18 15:34:41 -05:00
Scott Olsen
3c95c4baeb Use unsafe as a prefix in unsafe functions
This brings our function naming scheme into parallelism with other core
modules (e.g. Array.carp).
2020-02-18 13:56:52 -05:00
Scott Olsen
6fc0562028 Group functions by int type 2020-02-18 13:50:07 -05:00
Scott Olsen
a0bb6c5242 Add functions for converting intN seq(uence)s to byte seqs 2020-02-18 13:45:18 -05:00
Scott Olsen
05ab70b196 Add UintN->Byte conversions
Note that we do not need an unsafe variant of these conversions since
they are simple projections to and from the Uint types.
2020-02-18 13:35:35 -05:00
Scott Olsen
b8afc39a3b Binary: Make names consistent. Update docs.
Specifically, we now reference the explicit unsigned int types we return
in the docs for each function, and I've dropped the term byte-seq in
favor of bytes in all cases.
2020-02-18 11:50:24 -05:00
Scott Olsen
511663409e Add safe variants of byte conversion functions
I've also adopted a new naming strategy for these functions--the seq in
byte-seq was redundant, so we now just name these bytes->intN-seq.
2020-02-18 11:41:29 -05:00
Scott Olsen
d3e198673b Use partitions in byte-seq->int16-seq-unsafe
This change brings the implementation of `byte-seq->int16-seq-unsafe`
into parity with the implementations of its 32 and 64 bit brethren.

I've also cleaned up some of my previous sloppiness:

- Correct function names in doc and sig annotations.
- Remove extra spaces before newlines.
2020-02-17 19:03:52 -05:00
Scott Olsen
38efca11fa Remove byte-seq->int8-seq-unsafe
This function is obsolete after the introduction of Int8.from-bytes
2020-02-17 18:47:51 -05:00
Scott Olsen
dec44984ca Use StdInt types in binary conversion functions 2020-02-17 16:04:09 -05:00
Scott Olsen
4faa721e1d Add a function for retrieving the system endianness
The technique here feels a bit hacky, but it's the common way to do it.
We exploit the fact that ints are 16bits and chars are 8bits to grab the
first byte in a systems int representation, which is indicative of its
endianness.
2020-02-17 15:38:55 -05:00