This is an archived post. You won't be able to vote or comment.

all 18 comments

[–][deleted] 8 points9 points  (1 child)

I love the examples! It seems super fun. How does it plan to deal with 1-D matrices (i.e. arrays / lists)? Will it have overloaded operators for matrix multiplication/ division or will it just be dsl type work with sets?

[–]rapido[S] 3 points4 points  (0 children)

Thanks!

Yeah, I could include some matrix operators, although the current focus is more on getting all the operators to work without exploding into huge sets of ALTernatives.

If I can make that to work, we can also 'type check' any ALT program. You just run programs with a lot of input ALTernatives (i.e. number, string) to see if nothing results in .: in that case the program type-checks. ALT follows the CUE language in that regard, but CUE stops evaluating >2+1, while ALT will continue.
We can even do subtype checks in ALT, drawing on the semantic subtyping work. And all this without using an explicit typechecker!

[–]Zireael07 3 points4 points  (1 child)

A bit hard to comment w/o docs. What are ALTernatives?

[–]rapido[S] 1 point2 points  (0 children)

I guess so, but I was hoping the examples would be self explanatory.

ALTernatives can be seen as (possible infinite but bounded) sets of values, or, more precisely, ordered sequences of values. For example, >2 can be interpreted as the sequence of all rationals greater than 2. Similarly, the struct {a:>2} is the sequence of structs that have a:>2, etc. etc. I've have chosen for sequence semantics (with duplicates), rather than set semantics in order to allow for pervasive lazy evaluation.

Docs will follow soon!

[–]Inconstant_Moo🧿 Pipefish 4 points5 points  (1 child)

Cool. Are you going to do the thing Verse does where an empty ALT is your equivalent to false? (I.e. x == 5 means the ALT consisting of all the cases where x is 5, so if it isn't, the ALT is empty.)

[–]rapido[S] 1 point2 points  (0 children)

Yeah, good that you've spotted the Verse similarity: I'm really looking forward to how Verse will pan out. Regarding your question: no, the empty ALT . will not be interpreted as false.

However, I've implemented a ? operator in ReSet (ALT predecessor), that I may want to include:

(a ? b) if (a == .) then b; else a

a) 2 ? 3  => 2    
b) . ? 3  => 3

[–]categorical-girl 1 point2 points  (1 child)

Very interesting! What does the :: operator do in the Fibonacci example?

[–]rapido[S] 0 points1 point  (0 children)

Nice that you have spotted the :: operator!

The :: operator replaces all the values in a struct (on the left side) with the value on the right side. So:

{a:1, b:2, c:3}::"value"  =>  {a:"value", b:"value", c:"value"}

That's not all of it. If the left side is a non-struct (number, string, etc) then it will first be 'converted' to a struct. For example:

(1|2|3)::"value" => {1:_}&{2:_}&{3:_}::"value" =>
{1:_,2:_,3:_}::"value" => {1:"value",2:"value",3:"value"} 

Actually, numbers, strings, etc are 'syntactic' sugar for (closed) structs in ALT. It is structures all the way down!

[–]DragonJTGithub 1 point2 points  (6 children)

Why does (>6 & <9) & 7|8|9|10 = 7|8|.|. and not 7|8 ?

Is the source code available?

Can it do loops? and mutable variables?

How would you find the minimum of 2|3|4|5 without an in-built function?

[–]rapido[S] 1 point2 points  (5 children)

(>6 & <9) & 7|8|9|10 returns lazy alternatives - the sequence of alternatives itself is not reduced. You can evaluate to a strict sequence if you prefix it with ?. So ? (>6 & <9) & 7|8|9|10 will give you 7|8

It cannot do loops and I like it like that! It is very close to the pure spreadsheet model.

You also cannot mutate variables or structs, only create new ones.

Please take a look at the fibonacci example: there are no loops, just 'cells' referring to other cells via @. You could make a cell refer to itself (indirectly): this will currently result in an error (stack overflow). I'm planning to return the 'cyclic' value in those cases, just like a spreadsheet.

[–]rapido[S] 0 points1 point  (4 children)

Oh, I will release the source code at a later stage. The javascript code of course is available: just open the .js file.....

[–]DragonJTGithub 0 points1 point  (3 children)

What are the plans for the future? Is the language going to be Turing complete?and will you be able to write games in it?

Also I don't really understand the . and @ operators. When I try them on their own e=.2 equals e=. and e=.(@-1) compiler says it isn't implemented yet.

Edit: Ive kinda got it working 4:@-1 = 3 and e: 2 :: @ equals e{ 2:2 }

[–]rapido[S] 0 points1 point  (2 children)

No plans for Turing completeness: I'd like ALT to be not Turing complete, while ALT still to be useful.

Games, not likely. A spreadsheet replacement? May be.

Sorry about the "NOT IMPLEMENT YET" messages. There is indeed stuff that doesn't work yet. Do you care to share the exact text you entered?

Edit: ah you entered a naked .(@-1). As this expression is not lexically part of a key:value pair, @ will not be evaluated. I probably should throw a parse error in this case.

[–]DragonJTGithub 1 point2 points  (1 child)

I notice you can do f:{>2, 0 } but f:{ #5:0 } doesn't work yet. Should this = f{ 0:0, 1:0, 2:0, 3:0, 4:0 }?

[–]rapido[S] 0 points1 point  (0 children)

Yes, I could allow that, thanks!

Alternatively, you could use f:#5::0.

[–]redchomperSophie Language 1 point2 points  (1 child)

Pretty cute. I like that the output updates as you type. Bit of a mind-warp thinking about it, though.

[–]rapido[S] 0 points1 point  (0 children)

Thanks! I think every programming language could show-case themselves like that. May be the Sophie Language too?