Commit Graph

21 Commits

Author SHA1 Message Date
Veit Heller
8c1999d656
feat: add fstr (#1142)
* feat: add fstr

* test: add fstr test

* fix: memory error in test

* fix: fix backslash parser

* feat: add octal escape literals
2021-01-26 06:18:16 +01:00
Veit Heller
bdaf96550f
refactor: use quasiquoting in STDLIB and go through array in quasiquote (#1135) 2021-01-21 06:20:03 +01: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
hellerve
3b0b032bdc core: fix fmt without arguments 2020-02-12 17:33:38 +01:00
hellerve
ee812b37e6 core: make subarry/substring slice 2020-02-11 09:09:30 +01:00
hellerve
3d1abf1469 commands: check char-at 2020-01-14 09:32:22 +01:00
hellerve
daf8f017c8 core: better error messages in fmt 2019-07-22 13:09:22 +02:00
hellerve
e9fcf87ff5 core: remove stringcopy.append 2019-05-27 18:05:44 +02:00
Erik Svedäng
0049c13111 Renamed 'defdynamic' to 'defndynamic'. 2019-03-13 18:49:48 +01:00
hellerve
9848e8fb34 multiple fixes:
- don’t do function copying in benchmarking
- fix the array_update benchmark
- add Filepath.file-from-path
- add tests for the `Filepath` module
- reformat a lot of documentation
2019-02-15 14:48:49 +01:00
Chris Hall
7c1dd210d7 Renaming: String.count -> String.length, Array.count -> Array.length
Issue #236
2018-05-23 10:03:42 +10:00
Chris Hall
b46b2a39e8 String.append is now by reference, StringCopy.append is by copy/linear
Adding memory leak tests to String.append and StringCopy.append

Issue #94
2018-05-20 14:16:10 +10:00
hellerve
f3e559dc28 docs: more documentation work 2018-05-12 16:08:48 +02:00
hellerve
1c07003167 core: fix bugs and unnecessary check in fmt 2018-01-15 12:04:12 +01:00
hellerve
e1b1667ea3 core: fix printing percent in format 2018-01-02 14:46:42 +01:00
hellerve
7c9eaeac9f core: made format not leak memory; test: added test for format and fmt 2017-12-30 20:16:31 +01:00
hellerve
8baffc1f77 core: fixed format on last arg 2017-12-30 18:21:59 +01:00
hellerve
2c529eba43 core: check whether too many arguments are there for the format string 2017-12-30 15:19:43 +01:00
hellerve
ff34744dc4 core: format works! 2017-12-30 15:13:58 +01:00
hellerve
38d7bcd32a format macro works 2017-12-30 15:13:00 +01:00
hellerve
85ce16d5db core & compiler: initial work on #108 2017-12-30 15:13:00 +01:00