Commit Graph

1089 Commits

Author SHA1 Message Date
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
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
Scott Olsen
9329662fbb Merge branch 'master' of https://github.com/carp-lang/Carp into binary 2020-02-17 14:45:26 -05:00
hellerve
657f27c6ac core: add stdint types 2020-02-17 10:42:07 +01:00
Scott Olsen
6d1ddf41cf Cleanup partition refactor
Remove an unnecessary let clause.
2020-02-16 16:00:04 -05:00
Scott Olsen
d3f99487db Move partition function into the Array module
Since the function is generic over arrays, it makes more sense to house
it here.

I've also fixed an issue with its definition whereby we produced extra
empty arrays when n was greater than the original array length. We now
return an array of a length that matches precisely the number of
partitions with values we're able to create.
2020-02-16 15:57:38 -05:00
Scott Olsen
ea1505779d Add Binary module
The binary module implements functions for interpreting byte sequences
as int16, int32, or int64 values depending on a given endianess (the
Byte module implements support for interpreting bytes as int8 values).

It'd be nice if we could implement these functions in pure Carp, using
the Bytes module--but unfortunately we need to rely on some type
conversions in C, which are only possible by registering C functions for
performing the necessary conversions.

At the moment, all of these functions are unsafe (they access byte
arrays using unsafe-nth).
2020-02-16 15:15:54 -05:00
Erik Svedäng
761789b2ff
Merge pull request #682 from hellerve/veit/doall
Readd old foreach as doall
2020-02-14 15:43:46 +01:00
hellerve
c78c936016 core: readd old foreach as doall 2020-02-14 15:32:15 +01:00
Erik Svedäng
e6ebc5da13 Merge branch 'veit/genericize-for' of https://github.com/hellerve/Carp into hellerve-veit/genericize-for 2020-02-14 10:44:29 +01:00
Erik Svedäng
0223f6d381
Merge pull request #679 from hellerve/veit/long-laws
Add Long.MAX, Long.MIN, and Long.zero
2020-02-14 10:43:07 +01:00
Erik Svedäng
381494bb4a
Merge pull request #676 from hellerve/veit/starts-with-check
core: add check in starts-with?/ends-with? for string length
2020-02-14 10:31:50 +01:00
hellerve
c89d79b359 core: add additional custom comparator to for 2020-02-13 16:02:49 +01:00
hellerve
ae3f9c49b8 core: add Long.MAX, Long.MIN, and Long.zero 2020-02-13 16:00:53 +01:00
hellerve
0328b8a28a core: remove old definition of String.ends-with? (thanks @davidrusu) 2020-02-12 19:05:00 +01:00
hellerve
3b0b032bdc core: fix fmt without arguments 2020-02-12 17:33:38 +01:00
hellerve
e9d04ce1b9 core: add check in starts-with?/ends-with? for string length 2020-02-12 17:22:03 +01:00
hellerve
ee812b37e6 core: make subarry/substring slice 2020-02-11 09:09:30 +01:00
hellerve
66431a4c80 pattern: fix captures, add split and global-match-str 2020-02-09 13:42:39 +01:00
hellerve
d7cf3982f8 pattern: fix newline, tab, and carriage return treatment 2020-02-09 12:58:53 +01:00
Erik Svedäng
6ddf0e8f2b FIX! Avoid having to use temporary variables to help lifetime
checker.

In Concretize.hs, 'manageMemory' visits all args BEFORE managing their variables, making
it possible to apply functions to args "at the same time" as passing
them to the function.

Example:

(let [n (Array.unsafe-nth &b idx)
  new-b (Bucket.shrink @n k)]
  (Array.aset b idx new-b))))))

becomes

(let [n (Array.unsafe-nth &b idx)]
  (Array.aset b idx (Bucket.shrink @n k)))))))
2020-02-07 16:01:33 +01:00
Erik Svedäng
b7de401b82 Fixed broken code because of unsafe-nth. 2020-02-07 15:06:21 +01:00
Erik Svedäng
4fe7ea072b Merge branch 'master' into lifetimez-with-lambdas 2020-02-07 14:34:13 +01:00
Erik Svedäng
5eb603e470
Merge pull request #656 from hellerve/master
Make foreach (almost) hygienic
2020-01-30 14:36:55 +01:00
Erik Svedäng
248f84b1a7
Merge pull request #657 from sdilts/add-missing-header
Add missing #include <stdint.h> to carp_byte.h
2020-01-30 14:36:48 +01:00
sdilts
870b71e651 Add missing include directive
+ Missing stdint.h in carp_byte.h
2020-01-29 11:08:05 -07:00
hellerve
07fb17b753 core: make foreach loop counter hygienic 2020-01-29 15:48:02 +01:00
Erik Svedäng
bd7167986e
Merge pull request #653 from hellerve/veit/from-string
Add Float.from-string and Double.from-string
2020-01-29 15:06:31 +01:00
Erik Svedäng
9a8ce8fc99
Merge pull request #655 from hellerve/veit/char-zero-type
core: fix type of Char.zero
2020-01-29 15:01:57 +01:00
hellerve
43e4875138 core: make foreach (almost) hygienic 2020-01-29 11:55:56 +01:00
hellerve
07a21d76b5 core: fix type of Char.zero 2020-01-29 11:48:31 +01:00
hellerve
c0c31b6ad1 core: add Float.from-string and Double.from-string 2020-01-29 11:41:06 +01:00
Erik Svedäng
d9a2da18b0
Merge pull request #652 from hellerve/veit/const
Add const
2020-01-29 11:02:40 +01:00
hellerve
6c1901cccb core: add const 2020-01-28 19:31:05 +01:00
Erik Svedäng
1cc751afbb
Merge pull request #651 from hellerve/veit/use-sprintf
Use snprintf only when checking length
2020-01-28 16:19:44 +01:00
Erik Svedäng
148add054f
Merge pull request #649 from hellerve/veit/reformat-core
Reformat carp_string and carp_byte
2020-01-28 15:24:00 +01:00
Erik Svedäng
60d98a8c15
Merge pull request #648 from hellerve/veit-cleanup-bench
Move get-time-elapsed into Bench module
2020-01-28 15:21:13 +01:00
hellerve
9a431b1f54 core: use memcpy in String_append 2020-01-27 23:11:45 +01:00
hellerve
657f6c9d3a all: use snprintf only when checking length 2020-01-27 22:43:11 +01:00
hellerve
ac73729edf core: better performing Map./Set.put! 2020-01-27 16:58:10 +01:00
hellerve
78cdcb46e7 core: reformat 2020-01-27 16:57:08 +01:00
hellerve
1b7e027642 core: move elapsed_time into bench module 2020-01-27 16:56:22 +01:00
Erik Svedäng
ea045be426 Merge branch 'byte-type' of https://github.com/hellerve/Carp into hellerve-byte-type 2020-01-27 10:10:58 +01:00
Erik Svedäng
4801fec15d Merge branch 'veit/apply-ref' of https://github.com/hellerve/Carp into hellerve-veit/apply-ref 2020-01-27 10:07:50 +01:00
hellerve
95739d0cea core: add IO.getenv 2020-01-25 14:23:14 +01:00
hellerve
3ebe10d587 core: make Maybe.apply take function ref 2020-01-25 14:08:37 +01:00
Erik Svedäng
afea0555b1
Merge pull request #644 from hellerve/reformat-core
core: reformat core.h
2020-01-23 10:15:36 +01:00
Erik Svedäng
773824f5e7 Merge branch 'master' of https://github.com/hellerve/Carp 2020-01-23 10:12:34 +01:00
hellerve
09404798c2 core: add Result.map-error 2020-01-22 12:36:03 +01:00
hellerve
ab5cbb3a49 core: reformat core.h 2020-01-22 12:18:03 +01:00
hellerve
65db2bc2a8 macros: add comp 2020-01-15 16:52:36 +01:00
Erik Svedäng
bd397f8d50
Merge pull request #635 from hellerve/string-from-cstr
core: add String.from-cstr
2020-01-15 09:44:05 +01:00
Erik Svedäng
0ca676f337
Merge pull request #634 from hellerve/make-result-fns-ref
core: make result functions take refs
2020-01-14 10:52:05 +01:00
hellerve
cc6774ef8c core: make String.from-cstr copy 2020-01-14 10:08:29 +01:00
hellerve
3d1abf1469 commands: check char-at 2020-01-14 09:32:22 +01:00
hellerve
cd0c09da3f core: add String.from-cstr 2020-01-13 22:49:23 +01:00
hellerve
40f3975937 core: make result functions take refs 2020-01-13 22:40:20 +01:00
Erik Svedäng
d0f2c447be
Merge pull request #632 from hellerve/fix-array-reduce-example
Fix example in Array.reduce documentation
2020-01-07 10:39:18 +01:00
hellerve
a67c33d2f5 core: fix example in Array.reduce (thanks @Emiluren) 2020-01-06 23:29:49 +01:00
Erik Svedäng
11be440fab Work around defdynamic-once not working inside modules for now. 2019-12-18 12:35:27 +01:00
Erik Svedäng
50d91859c4 Merge branch 'master' of https://github.com/carp-lang/Carp 2019-12-18 12:11:50 +01:00
Erik Svedäng
7c15ec299b 'defined?' and 'defdynamic-once' 2019-12-18 12:10:47 +01:00
Erik Svedäng
2926abd1c8 Got rid of all but one compiler complaints on Windows. 2019-12-18 11:33:42 +01:00
Erik Svedäng
99bf013b81
Merge pull request #626 from nateupstairs/master
[win] attempt to fix windows compilation
2019-11-29 14:15:32 +01:00
Erik Svedäng
a6fb8c2515
Merge pull request #625 from hellerve/map->
RFC: Add Array.unreduce
2019-11-27 10:58:27 +01:00
hellerve
231b0a1d97 macros: fix nthcdr like @scolsen suggested 2019-11-26 07:13:14 +01:00
Erik Svedäng
e850da236f
Merge pull request #622 from hellerve/cxr
macros: add cxr, nthcar, and nthcdr
2019-11-25 12:58:24 +01:00
Erik Svedäng
81776b9635 Merge branch 'master' into hellerve-until 2019-11-25 12:44:14 +01:00
Erik Svedäng
34c314e6fe
Merge pull request #618 from sdilts/fopen-safe
Add open-file function
2019-11-25 12:42:42 +01:00
Erik Svedäng
cf276f4488
Merge pull request #608 from hellerve/pointer-arith
Add pointer arithmetic
2019-11-25 12:36:10 +01:00
Erik Svedäng
576dad0984 Merge branch 'master' into lifetimez-with-lambdas 2019-11-25 12:22:04 +01:00
hellerve
6bf45e16a6 macros: add until 2019-11-22 13:10:36 +01:00
hellerve
b1b84c8e3a core: rename map-> to unreduce 2019-11-21 11:05:21 +01:00
nateupstairs
539804d9b0 [win] attempt to fix windows compilation 2019-11-20 13:26:59 -08:00
hellerve
48b8b4ec13 core: add Array.map-> 2019-11-13 10:47:22 +01:00
hellerve
bc87e82d9f macros: add cxr, nthcar, and nthcdr 2019-11-09 12:52:11 +01:00
sdilts
5614103107 open-file: Return the value of errno instead of an error string 2019-11-01 17:28:52 -06:00
sdilts
77614b21d9 Add errno to System.carp
+ Error values included are those that can be set from calling `fopen`
+ Change order of imports so that the System module is available before the IO module
2019-11-01 17:26:56 -06:00
sdilts
0386971f00 Add open-file function
`fopen` returns a nullable pointer, which doesn't fit very well with
Carp's notions of saftey and error handling. Instead, return a
`Result` type that forces the user to check if the operation was
successful.
+ Can't call the function fopen because we can't overload a C
  function.
+ Leave `fopen` public in the IO module so extant code doesn't need to
  be changed.
2019-11-01 14:54:18 -06:00
hellerve
98bc275ea5 core: add Byte.hash 2019-11-01 10:52:34 +01:00
hellerve
15c27bdb49 core: allow byte as member type 2019-11-01 10:52:34 +01:00
hellerve
f1f252639f core: add a byte type 2019-11-01 10:52:34 +01:00
Erik Svedäng
16e9418d25
Merge pull request #616 from GrayJack/unsafe_fn
Rename known unsafe function to make clear that they're unsafe
2019-11-01 10:08:42 +01:00
GrayJack
52ce78ab13 Fix wrong parameter usage 2019-11-01 03:19:02 -03:00
GrayJack
d852662002 Added safe version of nth 2019-10-31 19:14:44 -03:00
Erik Svedäng
e90a123274 Merge branch 'includes' of https://github.com/GrayJack/Carp into GrayJack-includes 2019-10-31 14:30:07 +01:00
GrayJack
07def7db23 Fix all nth usage 2019-10-31 06:23:23 -03:00
Erik Svedäng
84afdb2575
Merge pull request #609 from hellerve/clang-format
Add .clang-format
2019-10-31 09:48:15 +01:00
GrayJack
2ac9d7fc12 Add 2 missing includes on core/Core.carp 2019-10-31 05:42:14 -03:00
GrayJack
2c0fcbd6c9 Changes Maybe.ptr to Maybe.unsafe-ptr and all it's ocurrences 2019-10-31 05:38:47 -03:00
hellerve
1829df07a5 core: do not have short functions on single lines 2019-10-30 11:07:32 +01:00
Erik Svedäng
c90d11b7ca
Merge pull request #606 from hellerve/better-repeat
Reduce allocations in String.repeat
2019-10-30 10:09:51 +01:00
Erik Svedäng
32a63d6def
Merge pull request #605 from hellerve/heap-without-copy
Reduce copies in heap
2019-10-30 10:05:11 +01:00
hellerve
65946224f0 core: add .clang-format (references #499) 2019-10-30 08:47:36 +01:00
hellerve
2819d22729 core: add pointer arithmetic (references #423) 2019-10-30 08:09:18 +01:00
Erik Svedäng
bfbd86711b Merge branch 'master' into lifetimez-with-lambdas 2019-10-29 10:17:19 +01:00
hellerve
c6dafda518 core: reduce allocations in String.repeat 2019-10-28 18:13:40 +01:00
hellerve
fc204fff1e core: reduce copies in heap 2019-10-28 17:23:46 +01:00
hellerve
eb9c236249 core: simplify Char.meaning 2019-10-28 17:19:31 +01:00
hellerve
e33c5fd7b4 core: actually register error 2019-10-28 14:28:37 +01:00
Erik Svedäng
6c9a6c0671 All tests run (yay). 2019-10-23 16:38:00 +02:00
Erik Svedäng
211cfdf65c Some hackery to get the Map module to not emit lifetime warnings. 2019-10-21 10:23:19 +02:00
Erik Svedäng
09f2dd7e23 Can load the core library without complaints. Tests still fail. 2019-10-18 14:40:20 +02:00
Erik Svedäng
24b76f57af
Merge pull request #586 from zxygentoo/master
Fix Generics.approx doc name.
2019-10-15 09:15:58 +02:00
Jorge Acereda
c4957020dd Add CARP_REALLOC() so it can be checked with CHECK_ALLOCATIONS 2019-10-13 10:40:54 +02:00
zxygentoo
4e0fd0a1ac Fix Generics.approx doc name. 2019-10-09 14:36:59 +08:00
Jorge Acereda
4a4107fffd Preserve includes order in generated output. 2019-10-03 00:23:27 +02:00
Erik Svedäng
1a0b003745 Remove defn for /= 2019-09-27 15:48:10 +02:00
Erik Svedäng
e8e641de99 Merge branch 'misc-fixes' of https://github.com/jacereda/Carp into jacereda-misc-fixes 2019-09-27 15:37:36 +02:00
Jorge Acereda
7b7cb5d1e5 Substitute /= interface by a generic. 2019-09-20 23:49:20 +02:00
Jorge Acereda
336b43a2af Add DoubleRef./= 2019-09-18 18:51:36 +02:00
Jorge Acereda
0423f40b51 Avoid copies. 2019-09-17 19:34:54 +02:00
Jorge Acereda
99ffd8efb7 Fix private? and hidden?. 2019-09-17 19:34:34 +02:00
Erik Svedäng
9e4f69ce5b Merge branch 'string-join-ref' of https://github.com/hellerve/Carp into hellerve-string-join-ref 2019-09-17 14:37:12 +02:00
hellerve
aad568c941 core: make String.join take ref (for #562) 2019-09-16 20:22:01 +02:00
Erik Svedäng
e455bab500 Array.contains? 2019-09-16 15:33:18 +02:00
Scott Olsen
c049394fa3 Macros: Make map more lispy
I've updated the implementation of map to make it similar to
implementations in other lisps. Calling map either calls an
implementation of the traditional `map` if a single list is provided as
an argument, or to `zip/zip-with` if multiple forms are provided as
arguments.

In order to facilitate this implementation, I've also implemented
several utility functions:

empty?: returns true if a data literal is empty.
and-internal: boolean and (the prior and macro doesn't work for our
purposes because it returns a form).
or-internal: boolean or, ditto regarding the existing or macro.
apply: applies a function to a list of arguments.
zip-internal: the implementation of zip-with we use in map.
reduce: works in the traditional way, folds a list of values into a
single value using a binary function and some initial value.
2019-09-14 23:54:56 -04:00
Erik Svedäng
0567c8ef14 Some docs for the SDL bindings. 2019-09-13 12:37:06 +02:00
Erik Svedäng
e4dceb2405 More functional event handler in SDLApp. 2019-09-13 12:09:11 +02:00
Jorge Acereda
57e46cc4db Use get-tag. 2019-09-11 20:37:15 +02:00
Jorge Acereda
df72627974 Fix doc 2019-09-11 20:24:09 +02:00
Jorge Acereda
c14a38a457 Remove str, fix hash/=. 2019-09-11 20:24:09 +02:00
Jorge Acereda
85cacf538f Stronger types for Color 2019-09-11 20:24:09 +02:00
hellerve
ba1fb68fe1 core: add dynamic string functions tail, prefix, and suffix 2019-09-11 15:03:44 +02:00
Erik Svedäng
ec9fc0f493
Merge pull request #550 from jacereda/typos
Fix some typos.
2019-09-11 11:11:39 +02:00
Jorge Acereda
8162deb1bb Fix gcc9 warning. 2019-09-11 08:33:38 +02:00
Jorge Acereda
cb9ff267b6 Fix some typos. 2019-09-11 08:21:42 +02:00
Scott Olsen
b9c0aa1bee Macros: Add map dynamic function
Adds a `map` function to the dynamic module. This function takes some
function (perhaps we should restrict it to only accept dynamic
functions?) and one or more forms. It returns a list data literal
containing the results of applying the function to each form.
2019-09-10 21:51:53 -04:00
Jorge Acereda
aa71647d02 Fix crashes in String.join/join-with-char with empty array. 2019-09-10 21:49:00 +02:00
Jorge Acereda
d29ff19968 Remove #516 workaround. 2019-09-10 20:46:09 +02:00
Erik Svedäng
6d6f93ec28
Merge pull request #542 from hellerve/gensym
Add gensym
2019-09-10 11:13:36 +02:00
Erik Svedäng
a6d4358ead
Merge pull request #541 from jacereda/generics2
Working on generics.
2019-09-10 10:55:10 +02:00
hellerve
439f734809 core: add gensym-with 2019-09-09 22:33:56 +02:00
Jorge Acereda
99516122b1 Generics no longer propagated. 2019-09-09 22:08:50 +02:00
Erik Svedäng
e40dfc57d7
Merge pull request #536 from scolsen/array-list-dynamics
Macros: Add dynamic list to array transforms
2019-09-09 21:43:04 +02:00
hellerve
a2c859c586 all: remove local-include in favor of relative-include 2019-09-09 17:56:43 +02:00