lone-lang / lone Goto Github PK
View Code? Open in Web Editor NEWThe standalone Linux Lisp
License: GNU Affero General Public License v3.0
The standalone Linux Lisp
License: GNU Affero General Public License v3.0
Hi! I haven't used the project yet, so feel free to dismiss the ideas. But here goes nothing: what about supporting Windows and Mac too, using the techniques from https://justine.lol/ape.html ?
Hi there! I came from your Reddit post and found this project fascinating.
While reading the sources, I've found the header include/lone/types.h
, which uses a common technique of tagged unions. Most notably, struct lone_value
:
struct lone_value {
// Auxiliary data...
enum lone_type type;
union {
struct lone_module module;
struct lone_function function;
struct lone_primitive primitive;
struct lone_list list;
struct lone_vector vector;
struct lone_table table;
struct lone_bytes bytes;
struct lone_pointer pointer;
long integer;
};
};
The downside of this approach is that it's possible to mess up during case analysis by 1) not checking a tag, or by 2) checking a tag A
and then using B
. The compiler cannot check this automatically, causing the bug to silently creep into the final executable.
Instead of managing tagged unions manually, I would suggest using Datatype99, which is a header-only library designed specifically to deal with the problem of tagged unions. struct lone_value
would look as follows 1:
datatype(
LoneValue,
(LoneModule, struct lone_module),
(LoneFunction, struct lone_function),
(LonePrimitive, struct lone_primitive),
(LoneList, struct lone_list),
(LoneVector, struct lone_vector),
(LoneTable, struct lone_table),
(LoneBytes, struct lone_bytes),
(LonePointer, struct lone_pointer),
(LoneInteger, long)
);
And case-analyzed as follows:
void handle(LoneValue value) {
match(value) {
of(LoneModule, module) { /* ... */ }
of(LoneFunction, function) { /* ... */ }
of(LonePrimitive, primitive) { /* ... */ }
of(LoneList, list) { /* ... */ }
of(LoneVector, vector) { /* ... */ }
of(LoneTable, table) { /* ... */ }
of(LoneBytes, bytes) { /* ... */ }
of(LonePointer, pointer) { /* ... */ }
of(LoneInteger, integer) { /* ... */ }
}
}
Since of
explicitly provides a variable binding, such as module
or function
, it's now much harder to make a mistake. The datatype
encoding is also more concise than the corresponding tagged union representation, since the former defines both enum lone_type
and struct lone_value
2.
Since Datatype99 has no run-time dependencies (not even the C standard library), and has a transparent and formally specified semantics, I think it might be a great fit for Lone 3.
Let me know if you have any thoughts or questions, which I should be able to answer.
I appreciate it may not be done yet, but the ability to make fat UI applications (or not) would be a great addition to the list.
Context: QML is interesting, but I think they missed an opportunity - https://paulhammant.com/2016/11/15/qmls-squandered-opportunity/. In that post I talk of a calculator and there are loads of attempts at making it as a demo in different techs. The web has many, and one or two are "single file" for that. Of course Lisp is the grandpappy language for elegant pseudo-declarative apps - https://paulhammant.com/2013/03/28/interface-builders-alternative-lisp-timeline so I'd imagine it was possible and terse/elegant. That's racing ahead as lone-lang should note whether it can do UI or not :)
Great work though!
GCC stack smashing protection references:
When stack smashing protection is turned on, the compiler generates some fairly simple code:
extern uintptr_t __stack_chk_guard;
noreturn void __stack_chk_fail(void);
void foo(const char* str)
{
uintptr_t canary = __stack_chk_guard;
/* ... */
if ( (canary = canary ^ __stack_chk_guard) != 0 )
__stack_chk_fail();
}
It looks like all we have to do is initialize __stack_chk_guard
to a random number and provide a __stack_chk_fail
function which exits the program. Linux provides 16 random bytes to every process via the auxiliary vector and lone already uses those to initialize its hash functions. It should be possible to use those random bytes to initialize the stack canary as well.
Originally posted by @matheusmoreira in #3 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.