Carp/core
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
..
Array.carp core: move range into array ext and add unsafe-range 2020-05-21 15:23:29 +02:00
ArrayExt.carp core: update dcostring for range-or-default 2020-05-24 12:51:11 +02:00
Bench.carp core: move elapsed_time into bench module 2020-01-27 16:56:22 +01:00
Binary.carp Move Byte Order type outside of the Binary module 2020-03-20 19:02:55 -04:00
Bool.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Byte.carp Add an implements primitive, update core 2020-05-09 12:59:47 -04:00
carp_bench.h core: move elapsed_time into bench module 2020-01-27 16:56:22 +01:00
carp_binary.h all: various long fixes 2020-04-23 21:50:30 +02:00
carp_bool.h core: do not have short functions on single lines 2019-10-30 11:07:32 +01:00
carp_byte.h 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
carp_char.h Merge 2020-05-11 16:10:35 +02:00
carp_debug.h Preserve includes order in generated output. 2019-10-03 00:23:27 +02:00
carp_double.h Long type to ensure longs are actually 64 bits. 2020-04-22 10:40:06 +02:00
carp_float.h core: do not have short functions on single lines 2019-10-30 11:07:32 +01:00
carp_int.h core: do not have short functions on single lines 2019-10-30 11:07:32 +01:00
carp_io.h Hopefully portable and simple get-line. 2020-05-11 16:08:40 +02:00
carp_long.h Detect __builtin_x_overflow() based on __GNUC__ macro. 2020-05-23 19:03:07 +02:00
carp_memory.h all: various long fixes 2020-04-23 21:50:30 +02:00
carp_pattern.h Remove braces so different clang-formats output the same. 2020-05-30 09:32:50 +02:00
carp_safe_int.h Detect __builtin_x_overflow() based on __GNUC__ macro. 2020-05-23 19:03:07 +02:00
carp_stdbool.h core: remove stdbool dependency 2018-11-17 15:42:36 +01:00
carp_stdint.h all: various long fixes 2020-04-23 21:50:30 +02:00
carp_string.h Merge pull request #799 from hellerve/veit/string-to-bytes 2020-05-13 20:59:37 +02:00
carp_system.h Ignoring system() return value produces warnings on some systems, just return it. 2020-05-11 16:08:40 +02:00
carp_utf8.h Roll our own UTF-8 support. 2020-05-12 01:14:02 +02:00
Char.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Collection.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Color.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Control.carp Fix signature of Control.iterate-until 2020-05-20 23:40:46 -04:00
Core.carp Merge pull request #815 from hellerve/veit/fix-776 2020-05-26 20:55:16 +02:00
core.h Don't include windows.h on mingw. 2020-05-12 01:13:36 +02:00
Debug.carp core: fix Debug.trace for new evaluator 2020-05-16 12:46:05 +02:00
Double.carp Add remaining implements declarations 2020-05-10 22:53:35 -04:00
Dynamic.carp Add pkgconfigflags. 2020-06-01 21:34:12 +02:00
Filepath.carp core: make subarry/substring slice 2020-02-11 09:09:30 +01:00
Float.carp core: add implements for FloatRef comparators 2020-05-12 22:45:29 +02:00
Format.carp Implement private 2020-06-19 10:30:55 -04:00
Generics.carp core: fix typo in docs for Generis.approx 2020-05-13 16:45:11 +02:00
Geometry.carp Generics no longer propagated. 2019-09-09 22:08:50 +02:00
GLFW.carp Added some of GLFW constants 2020-06-18 23:19:31 +02:00
Heap.carp Fix all nth usage 2019-10-31 06:23:23 -03:00
Int.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Interfaces.carp Added support for (load-once). 2020-05-05 15:00:57 +02:00
Introspect.carp Fix length checks, use or 2020-05-27 15:22:42 -04:00
IO.carp Merge 2020-05-11 16:10:35 +02:00
Long.carp core: add missing longref implements procs 2020-05-18 23:02:26 +02:00
Macros.carp core: update doc of cond 2020-05-26 21:50:26 +02:00
Map.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
Maybe.carp core: make NULL Ptr a instead of a 2020-05-18 23:21:16 +02:00
OpenGL.carp Add pkgconfigflags. 2020-06-01 21:34:12 +02:00
Pattern.carp Merge pull request #769 from scolsen/implement-prim 2020-05-12 21:45:29 +02:00
Phantom.carp core: add docs for phantom 2020-06-17 19:06:49 +02:00
Pointer.carp core: add String.to-bytes 2020-05-13 17:15:26 +02:00
Random.carp Add an implements primitive, update core 2020-05-09 12:59:47 -04:00
Result.carp Add some more calls to implement to make tests pass 2020-05-10 13:32:22 -04:00
SafeInt.carp Added --compile-fast to compile with tcc. 2020-05-21 20:04:54 +02:00
SDL_gfx.carp Refactored flags handling (add-pkg). 2019-06-17 09:02:34 +02:00
SDL_image.carp Merge 2020-05-11 16:10:35 +02:00
SDL_mixer.carp Merge 2020-05-11 16:10:35 +02:00
SDL_ttf.carp Merge 2020-05-11 16:10:35 +02:00
SDL.carp Merge pull request #769 from scolsen/implement-prim 2020-05-12 21:45:29 +02:00
SDLHelper.h all: fixes for new evaluator 2020-04-17 11:58:28 +02:00
Sort.carp core: add sort flavors with custom comparators 2018-11-13 11:11:21 +01:00
StaticArray.carp Add remaining implements declarations 2020-05-10 22:53:35 -04:00
Statistics.carp Fix all nth usage 2019-10-31 06:23:23 -03:00
StdInt.carp Merge pull request #769 from scolsen/implement-prim 2020-05-12 21:45:29 +02:00
String.carp Merge pull request #799 from hellerve/veit/string-to-bytes 2020-05-13 20:59:37 +02:00
System.carp Merge pull request #786 from hellerve/veit/move-to-templates 2020-05-12 22:24:54 +02:00
Test.carp test: add assert-ref-equal, assert-just, and assert-nothing 2020-05-12 14:53:42 +02:00
Tuples.carp core: autogenerate Tuple types and document 2020-05-24 11:49:27 +02:00
Unsafe.carp core: rearrange templates 2020-05-12 21:58:40 +02:00
Vector.carp Add remaining implements declarations 2020-05-10 22:53:35 -04:00