67 karma · joined Oct 29, 2018 (8y ago) · 94 submissions
comment 4y ago · link · parent
Force f = 5 kg * 9.807 m/s/s; // result: 49.035 Newtons
Area space = (20ft + 2in) * (37ft + 7.5in); // result: 758 37/48 ft²
All unit expressions internally store amounts as SI units, which enables interunit expressions.
Length height = 6 ft + 4 cm; // mix SI and US units
out.println(height.to(ft)); // display any unit
You aren't limited to units. Generally, any concatenative sequence can be implemented. Like ranges:
IntegerRange range = 1 to 5;
Here the `to` identifier's type implements reactions to Number types to produce range types, which enables:
for (int i: 1 to 5) { out.println(i); }
See the manifold project's Unit and Science modules:
Units: https://github.com/manifold-systems/manifold/tree/master/man...
Science: https://github.com/manifold-systems/manifold/tree/master/man...
comment 4y ago · link · parent
The idea with binding expressions is the type of expression A and the type of expression B implement "reactions" with one another in order to form a binding expression when they are lexically adjacent.
65 mph
The type of `mph` defines a post reaction method with the type of `65` as an argument that results in type Rate. As I understand it this is concatenative, right?
Another example:
Money payment = 1.5M USD;
There are tons of these.
Concatenative programming in general feels like it should have a more prominent place in mainstream languages. Just my take.
[1] https://github.com/manifold-systems/manifold/tree/master/man...
3.
Multiple return values for Java, also tuples, also 'auto'(github.com ↗)
1 points · by mckinney · 4y ago · discuss
4.
Java class objects aren’t OOP, should they be?(manifold.systems ↗)
2 points · by mckinney · 4y ago · discuss
comment 6y ago · link · parent
Yes, Manifold already supports Java 15 multi-line strings (aka text blocks) like this:
var myValue = """
[>.js<]
function foo() {
return "hi";
}
foo();
""";
You can embed a resource fragment as either a declaration or a value. You use a string to embed a value fragment as with the JS example above. Note the [>.js<] header indicates the resource type for the string, similar to your annotation. As you surmised, an expression such as a string literal cannot be annotated.comment 6y ago · link · parent
Well, if you want to leverage Java's static type system (and why not?), the answer is, yes. I imagine you'd want type and member references to the other language to resolve statically using the compiler, right? Similarly, why not have the same functionality in your IDE? Plus code completion, usage searching, refactoring?
Now, as I mentioned in an earlier comment, the embedding part of this addresses just a small segment of use-cases e.g., scoped query editing. The vast majority of other cases work directly against resource files, type-safely. Read more about that here:
comment 6y ago · link · parent
Well, not exactly. Most IDEs do NOT support clicking through a generated method call to the corresponding element in a resource file. Manifold is all about that. See it in action: http://manifold.systems/images/graphql.mp4
The Manifold fragments discussed here address only a narrow band of use-cases where embedding the resource improves the dev experience, like with queries and such. It's not for everyone, though.
comment 6y ago · link · parent
[1] https://github.com/manifold-systems/manifold/tree/master/man...
comment 6y ago · link · parent
[1] https://docs.oracle.com/javase/8/docs/jdk/api/javac/tree/com...
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
[1] https://github.com/manifold-systems/manifold/tree/master/man...
20.
Type-safely embed DSLs directly into Java(github.com ↗)
43 points · by mckinney · 6y ago · 25 comments
comment 6y ago · link · parent
[1] https://github.com/manifold-systems/manifold/tree/master/man...
comment 6y ago · link · parent
comment 6y ago · link · parent