* feat: Can omit .init in simple cases
* fix: Don't treat unqualified modules as interface sym:s
* feat: Can handle implicit init of type inside 'use':d module
* fix: Give deftypes and sumtypes correct parent environment!
* test: A few test cases
* refactor: Remove commented out code
Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
* docs: Remove a lot of duplicated information and refer to webpages instead
* fix: Remove line about (help), it does not make sense anymore
* fix: Add open-browser to nix config
Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
The `address` keyword is useful when one needs to circumvent Carp's
memory management for particular cases. However, the evaluator
previously didn't understand `address` in most contexts, so it proved
difficult to toy around with in the REPL.
This commit adds basic support for calling `address` in the REPL by
adding a case to the evaluator. This allows users to test out functions
that take `Ptr` arguments such as `Pointer.to-value`. The `address`
keyword only accepts a symbol as an argument (since getting the address
of a literal value doesn't always make sense (e.g. &2) and produces
invalid C):
(def a 1)
(address a)
=> a
(type (address a))
=> (Ptr Int)
(Pointer.to-value (address a))
=> 1
Note: one will still typically need to wrap it in a function in
higher-order contexts.
* chore: Moved examples that work more as tests to folder 'test/produces-output'
* fix: Corrections to the release script
* fix: Correct filename on Windows
* fix: Move more files around
* fix: Remove check-malloc example
* fix: Apparently unicode example does not work
* chore: Move nested_lambdas.carp back to examples
* chore: Remove .DS_Store files
* fix: Bring back unicode test
* test: Make sure benchmark compile (had to remove mandelbrot and n-bodies)
* fix: Replacement implementation of clock_gettime on Windows
* chore: Trigger CI
* fix: Define CLOCK_REALTIME
Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
* Adds C Interop documentation for Strings
* Replaces usage of triple backticks with single when used in a paragraph
* Adds link to new C Interop docs in the Language Guide
* Small tweaks to wording in C Interop doc
* Adds Array section to C Interop doc
* Adds deftemplate examples in C interop doc
* Small copy change in C interop doc
* Adds identifiers section in C interop doc
* Emit/Deftype: Add a few more special cases for Unit members
There were a few gaps remaining in our handling of Unit types as members
of user defined types, most notably, generic setters weren't handling
Units appropriately. This commit adds special checks for Unit types in
generic setters, and also accounts for a Unit refs:
- Specialize generic setter functions against Unit members
- Specialize calls to str/prn against Unit members in StructUtils
(rather than accessing the struct member, which doesn't exist in the
Unit case, we simple call Unit's prn function (added in the next
commit).
- Don't bind references to Unit values to variables. This fixes an error
whereby a reference to a Unit would generate invalid C such as:
`void* _9 = &;`
Likewise, we omit references to Units from function arguments just as
we omit Unit values.
* Unit: Add Unit type implementations for common interfaces.
Now that Unit can be used as a member type it is subject to several
interfaces, such as prn, that it previously hadn't implemented.
This commit adds Unit.carp to core which implements `prn`, `copy`, and
`zero` for the Unit type.
* Deftype: Return null pointers for Unit getters
This is *hopefully* one of the final updates needed to fully support
Unit's as member types. Getters for fields of such types have no struct
member to read, but are expected to return a void pointer; so we return
a NULL void pointer instead.
This commit also updates our emissions for function calls to prevent
assigning the results of functions with Unit and (Ref Unit) return types
to variables.
* Emit: Filter void args from lambda calls
Just as we filter void argument types from other function calls, we now
filter them from calls to lambdas.
Unit's show implementation defaults to the empty list `()`--this
presents problems when validating types, since generic type members are
replaced by the reification (a type literal) of their arguments. In the
`Unit` case, `()` yields some surprising invalid types.
So, we reify UnitTy as `Unit` instead to ensure consistency. This
permits using Unit as a member in generic types like Result.