Commit Graph

4906 Commits

Author SHA1 Message Date
rgkirch
998948ec6b
Update Install.md (#1324) 2021-10-11 16:02:33 +02:00
Scott Olsen
bd553fb78e
feat: add assignment operator macros (#1320)
These macros apply an operation to the current value of a variable and
then set the variable to the result of the application. They are
effectively sugar for writing `(set! <var> (<op> <var> <val>))` and
should be familiar to those who have programmed in imperative languages
like C.

In Carp, all the underlying operations these macros use are interfaces,
so one can flexibly use them for more than just numeric types.

Example usage:

```clojure
(let-do [dial 0]
  ;; crank it up to 11!
  (while-do (dial < 12)
    (++ dial))
  dial)

;; expanded
(let-do [dial 0]
  ;; crank it up to 11!
  (while-do (dial < 12)
    (set! dial (inc dial)))
  dial)
```
2021-09-27 10:15:54 +02:00
Veit Heller
0188264463
feat: add compiler error on maximum sumtype constructors (#1319) 2021-09-18 08:49:19 +02:00
Erik Svedäng
b745b1fcdb build: 0.5.3 2021-09-17 13:54:26 +02:00
Tim Dévé
cf3fddfe3a
ci: Merges different platform releases into one (#1313)
* ci: Merges different platform releases into one

* ci: Removes platform specific release pipelines
2021-09-17 13:49:06 +02:00
Veit Heller
0efb9825f0
feat: add Dynamic.List.find-index (#1316) 2021-09-17 05:58:39 +02:00
Veit Heller
e307654521
feat: add expand-compiled (#1310) 2021-09-17 05:57:50 +02:00
Veit Heller
5a449b0919
fix: use non-deprecated unlink function on windows (#1311) 2021-09-16 07:56:32 +02:00
Veit Heller
a4f8041288
fix: run ormolu and clang-format (#1312) 2021-09-15 19:49:20 +02:00
Tim Dévé
6a0af38026
ci: Runs nixpkgs workflow only on master (#1315) 2021-09-15 07:36:02 +02:00
Tim Dévé
267eece092
ci: Uses older windows version for CI (#1314) 2021-09-15 07:32:37 +02:00
Erik Svedäng
5cc691be56 build: 0.5.2 2021-09-08 19:59:00 +02:00
Scott Olsen
4630e0e6a5
feat: allow C types to satisfy all type constraints (#1306)
This commit builds on the emit-c feature by permitting C typed values to
be used anywhere in Carp code.

For example, if one wants to use the literal C macro `EDOM`:

```clojure
(register EDOM C "EDOM")

(Int.+ 1 EDOM)
=> 34
```

when compiled, this will produce the call:

```c
Int__PLUS(1, EDOM)
```

So it provides a quite flexible means of using C macros directly. It is,
of course, also radically unsafe. Anyone registering and using values of
the C type better be cautious.

One can get pretty crazy with this feature:

```clojure
(register comment-it C "// commented out;")

(Int.+ 1 comment-it)
=> int _11 = Int__PLUS_(1, // commented out;)
   int* _12 = &_11; // ref
   String _13 = IntRef_str(_12);
```
2021-09-04 15:08:51 +02:00
Erik Svedäng
d0a98a5065
fix: #1261 (#1272)
* Revert "refactor: Remove deps functions in ArrayTemplates (#1093)"

This reverts commit 861ba26f52.

* test: Regression test for issue #1261
2021-09-04 15:07:52 +02:00
Veit Heller
74d7d5767b
fix: elide void definitions (#1305) 2021-09-04 14:29:44 +02:00
Scott Olsen
ae2186f4b7
fix: Allow types defined in modules to be members (#1303)
This commit fixes issue #1302, whereby types defined in modules were not
recognized as valid member types by our validation routines.

We simply need to account for types defined in modules in the global
env, threading the global env along through validation (previously we
only passed the top-level type env, which contains no modules).
2021-09-04 14:27:48 +02:00
Scott Olsen
03b453cb36
fix: ensure interface values aren't discarded (#1308)
A call to sequence in our handling of polymorphics would result in
discarding legitimate interface implementation results in rare cases.
Calling rights instead fixes the issue. We also need to take the union
of the results to ensure we account for cases such as polymorphically
realized interfaces (e.g. the `prn` function for a (Maybe String), other
wise, we don't resolve to concrete polymorphics for types that have
ad hoc polymorphic members.

Fixes #1307
2021-09-04 14:27:07 +02:00
Scott Olsen
d2dd875935
feat: Add Float.round (#1301)
Just a wrapper around the c std function.
2021-08-23 20:31:29 +02:00
Scott Olsen
c9967ddf6e
feat: Add additional ignore macros (#1300)
* feat: Add additional ignore macros

This commit adds two new ignore macros, ignore*, which wraps an
arbitrary number of forms in calls to `ignore` and ignore-do, which
wraps an arbitrary number of forms in ignore, then bundles the whole in
a do call, effectively executing each form only for side effects and
ignoring all results.

* docs: Update ignore* docs

Link to `ignore` doc

Co-authored-by: Veit Heller <veit@veitheller.de>

* fix: Call ignore* in ignore-do

ignore-all was an old name that no longer exists!

* test: Add test for ignore-do

Co-authored-by: Veit Heller <veit@veitheller.de>
2021-08-23 20:31:10 +02:00
Scott Olsen
0c9c475e6c
fix: fix nested polymorphic types (#1294)
* refactor: refactor concretize module

This commit primarily refactors the concretize module, breaking out the
local definitions for visit functions into top level functions that are
hopefully easier to change. I've also modified some monadic code in the
interest of terseness.

This commit adds some additional patterns for XObj forms as well.

* refactor: Only export called functions in Concretize

Adds an export list to Concretize so that the module encapsulates those
functions that are only used internally within the module.

* refactor: better names in concretize functions

Clarify the names of variables in visitor type functions.

* refactor: ensure findType returns a type

Adds an additional check to findType that ensures the retrieved binder
is in fact a type and not another object. This is necessary for certain
contexts like type concretization since modules may also be designated
by symbols that refer to types.

* fix: ensure nested polymorphic types are emitted

This commit fixes an issue whereby nested polymorphic types would not be
emitted by the compiler, even though their member functions were
emitted.

In order to support this, we need to update a couple of functions to
take the global environment (to find nested types, which live in
modules) in addition to the top level type environment. Additionally, we
had to update scoring to account for nested names.

fixes #1293

* test: add tests for nested polymorphic types

Adds regression tests to ensure nested polymorphic types are concretized
and emitted correctly.
2021-08-10 08:41:20 +02:00
Scott Olsen
b74e674bb1
refactor: Cleanup Concretize module (#1283)
* refactor: refactor concretize module

This commit primarily refactors the concretize module, breaking out the
local definitions for visit functions into top level functions that are
hopefully easier to change. I've also modified some monadic code in the
interest of terseness.

This commit adds some additional patterns for XObj forms as well.

* refactor: Only export called functions in Concretize

Adds an export list to Concretize so that the module encapsulates those
functions that are only used internally within the module.

* refactor: better names in concretize functions

Clarify the names of variables in visitor type functions.
2021-08-05 07:36:29 +02:00
Scott Olsen
50680e921a
fix: Fix scoring of type and function declarations (#1290)
Previously, there was an edge case whereby types that depended on other
types that were not scored yet and functions that in turn depended on
these types could be assigned the same score. When this happened, we'd
sometimes incorrectly emit functions before the struct types they
depended on.

Since functions are always at the bottom of a type hierarchy (they
always depend on their members), there's a simple fix: we just add 1 to
ensure functions are emitted after type declarations in all possible
cases.
2021-07-30 09:27:10 +02:00
Veit Heller
39e8fc6d24
fix: escape quotes in String.prn (#1287) 2021-07-29 08:30:42 +02:00
Scott Olsen
98acdb53e9
fix: make Symbol.prefix work on qualified symbols (#1286)
This commit makes it so that `Symbol.prefix` can take qualified symbols
as prefix arguments, e.g.

`(Symbol.prefix 'Foo.Bar 'baz) => 'Foo.Bar.baz`
2021-07-29 08:26:31 +02:00
Veit Heller
cbdf425247
fix: respect line number in repl (#1282)
* fix: respect line number in repl

* refactor: simplify Parse.parse

* fix: multiline line counter in repl
2021-07-23 21:24:59 +02:00
Veit Heller
760726e001
fix: fix dynamic let bindings recursion and binder leaks (#1281) 2021-07-15 22:45:05 +02:00
Veit Heller
f3944ce73d
feat: add Dynamic.Debug.trace (#1279) 2021-07-14 08:14:07 +02:00
Veit Heller
74d64a85bb
feat: add Dynamic.proc? (#1278) 2021-07-13 18:04:58 +02:00
Veit Heller
092b249ac7
feat: add List.remove-nth (#1277) 2021-07-13 17:54:15 +02:00
Veit Heller
fb1ee66ecc
feat: add machine-info primitive draft (#1269)
* feat: add machine-info primitive draft

* feat: rename machine-info to structured-info

* fix: use the right primitive name in structured-info error

* refactor: remove unnecessary code
2021-07-09 20:45:23 +02:00
Veit Heller
0adc1abd50
feat: allow for multibranches in case (#1276) 2021-07-08 20:43:48 +02:00
Veit Heller
ca0f9f7d4f
docs: set infoFile on primitives and commands (#1273) 2021-07-06 11:33:12 +02:00
Veit Heller
00c85cac42
fix: whitespace in context errors (#1274) 2021-07-06 11:32:31 +02:00
Veit Heller
d3a6ca562f
docs: document core modules (#1271) 2021-07-05 14:48:35 +02:00
Veit Heller
aac92fe9dd
fix: set correct info on defmodule (#1270) 2021-07-03 13:00:14 +02:00
Veit Heller
39b1e8e5fa
docs: add pattern limitations (#1268)
* docs: add pattern limitations

* docs: incorporate feedback by @guberathome into pattern limitations
2021-07-02 10:41:49 +02:00
guberathome
45b70852dc
fix: added missing definitions so Carp can be used with TCC 32bit on Windows (#1267)
Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-07-01 10:20:42 +02:00
Veit Heller
97c0b5a61b
docs: make doc work on top level and document macros (#1265) 2021-07-01 09:42:37 +02:00
Erik Svedäng
09c91c7f90
feat: Emit docs for top level bindings (#1253)
* refactor: Tiny cleanup before we begin

* refactor: Moved module finding to its own local function

* feat: save-docs-internal is now a binary command

* feat: This seems to work

* fix: Cleaned up the code, save-docs now emit one module per file listed
2021-06-28 19:56:59 +02:00
guberathome
e412559380
reorganize Pattern library (#1257)
* feat!: implemented Pattern.match which returns start and end indizes of the first match

* fix: Pattern.match now returns correct end index

* feat: moved Pattern.match-str and Pattern.find from C to Carp code

* chore: fix build after merges

* chore: fix build after merges

* feat: moved Pattern.find-all from C to Carp code

* feat: Pattern.global-match-str no longer relies on Pattern.global-match

* docs: updated for Pattern.global-match

* fix: moved str/prn functions into sub module

* fix: removed unused functions from carp_pattern.h (using cflow)

* feat!: renamed (Pattern.global-match) to (Pattern.match-all-groups)

* fix: unit test

* fix: some functions renamed to match Carp style

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-23 22:07:56 +02:00
Veit Heller
c592485783
fix: Dynamic.String.slice index handling (#1258) 2021-06-20 21:45:21 +02:00
guberathome
0d15a57d0e
(and) and (or) now handle any number of parameters (#1251)
* feat: generalized (and) and (or) to handle any number of parameters

* feat!: removed (and*) and (or*) macros

* chore: worked around compiler issue for unit test

* fix: unit test in ./test/macro.carp

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-20 21:44:04 +02:00
guberathome
0c038365d7
IO.Raw (#1243)
* feat!: move C library wrapper funtions to IO.Raw

* docs: fixed doc string for (String.allocated?)

* docs: removed superfluous parameter names for defns

* fix: replaces IO.exit by System.exit

* fix: ./test/regression.carp for (IO.read->EOF)

* fix: ./test/system.carp

* feat: implemented IO.fwrite!

* feat!: removed IO.exit

* feat!: raw character input now returns Int instead of Char

* fix: removed irritating space chars

* fix: repaired ./example/carp_demo.carp

* fix: reverted System.exit to return an Int for SDL examples

* fix: removed System.exit!

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-17 17:33:10 +02:00
Erik Svedäng
3b429541a3
refactor: Clean up memory management functions (#1240)
* refactor: Mid-refactor save point.

* feat: Code compiles

* refactor: Remove unused imports

* refactor: Move functions out of massive `manageMemory` block

* refactor: Move out even more functions from `manageMemory`

* refactor: Made most patterns match on "head form" of each s-expression

e.g. (if a b c) matches on 'if', 'a', 'b' and 'c'

* refactor: Use the pattern synonyms in Memory

* refactor: Remove a little cruft

* refactor: whenOK function

* refactor: Use 'whenRight' functions to avoid directly matching on Either

* docs: Comment the 'getConcretizedPath' function

* refactor: Move functionFinding-functions into Polymorphism module
2021-06-16 21:41:58 +02:00
guberathome
5e5cf8d4c2
Up down case (#1248)
* feat!: implemented String.ascii-to-lower and String.ascii-to-upper

* fix: corrected docstrings

* fix: added unit test for ascii-to-lower and ascii-to-upper

* fix: moved tolower- and toupper from String to Byte module

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-16 09:45:32 +02:00
Veit Heller
38951efc7d
fix: check for generic main at build time (#1247)
* fix: check for generic main at build time

* docs: add comment about main error handling in concretization
2021-06-16 09:40:28 +02:00
Tim Dévé
bfe30e9dd6
docs: Updates memory docs to discourage overriding delete (#1245) 2021-06-15 10:42:13 +02:00
Erik Svedäng
f4eb4b5e93
test: REPL (#1239) 2021-06-15 08:02:44 +02:00
Veit Heller
c149bfa7af
docs: document managed? primitive (#1244)
* docs: document managed? primitive

* docs: rewrite managed? docs
2021-06-14 09:50:04 +02:00
Veit Heller
f7785ad93d
fix: render submodules in html docs (#1242)
* fix: render submodules in html docs

* fix: also render deeply nested modules

* feat: no prefixes in nested submodule doc rendering

* fix:  fix text alignment of module index for sdl

* feat: make submodules expandable
2021-06-11 13:02:52 +02:00