News for hackers. Stuff that matters.
Re:Stabel: A pure, concatenative and statically typed progra... by Skinney on Wednesday June 16, 2021 @09:10AM (#27528110)
Yes. Stabel is staticly typed, and types are inferred if the type signature is left out. You could also write the code as:

    def: cube
    type: Int -- Int
    : dup dup * *
Re:Stabel: A pure, concatenative and statically typed progra... by tluyben2 on Wednesday June 16, 2021 @02:47PM (#27532028)
I never thought about this much but now and it has been so since Forth anyway: why are definitions prefix? Why do they not gobble up the stack? I always found it easier to create everything uniform like [0]. And I did that for many years with asm and c as well because I thought it was faster than porting something (it probably was not but he).

I just like to minimize exceptions to rules and this seems a weird one to me. But probably has reasons I am unaware of (besides subjective readability which is, of course a very good reason).

[0] https://gist.github.com/tluyben/16ee2645c4c8aed813005d51488d...

Re:Stabel: A pure, concatenative and statically typed progra... by retrac on Wednesday June 16, 2021 @05:44PM (#27533811)
Yes, in my own toy concatenative language, define is just a regular procedure. It takes two arguments off the stack. The first is a pointer to the name, the second is a pointer to a quotation with the definition body. It intentionally looks Forth-like but it's different under the hood:

    [ dup + ]      \ writes a lambda function to heap and push ptr
      : double ;   \ : writes the next symbol as a string to heap and push ptr
                   \ ; is define, writes definition into dict
The reason Forth did it the classic Forth way originally, I suspect, is because Forth's parser needs to be told to switch modes. Stop executing words directly and start compiling them. There isn't really anywhere to store a temporary string, so you need to tell it to start writing into the dictionary entry before you give it the string. In my language, using [ ] for quotations starts writing to the heap, which is also where strings go. This has the same practical effect.
Re:Stabel: A pure, concatenative and statically typed progra... by Skinney on Thursday June 17, 2021 @05:27AM (#27537737)
I agree in principle about the benefits of everything being uniform. For Stabel, specifically, I need some way of seperating function-definition from function-implementation, and a prefix meta language seemed like the best bet. Didn't look at it too closely, though.
Re:Stabel: A pure, concatenative and statically typed progra... by tluyben2 on Thursday June 17, 2021 @12:58PM (#27541786)
Thanks and, nice work with Stabel, we need more experiments in this space.
Re:Stabel: A pure, concatenative and statically typed progra... by a-nikolaev on Wednesday June 16, 2021 @10:08AM (#27528632)
Does Stable support polymorphic functions? What kinds of data abstractions are possible? (I.e. something like records / structs / classes / Lua-like tables?)
Re:Stabel: A pure, concatenative and statically typed progra... by Skinney on Thursday June 17, 2021 @05:28AM (#27537749)
Stabel has generics, but no protocols/interfaces/typeclasses _yet_.

Stabel allows you to define structs and unions, which gives you a lot of flexibility.

Re:Stabel: A pure, concatenative and statically typed progra... by mikewarot on Wednesday June 16, 2021 @09:12AM (#27528127)
Great, now could you have a second copy of cube that did floating point?
Re:Stabel: A pure, concatenative and statically typed progra... by Skinney on Wednesday June 16, 2021 @10:13AM (#27528692)
Stabel doesn’t have floats, yet, but when it does: yes, if you put it in a different module.
Re:Stabel: A pure, concatenative and statically typed progra... by thesz on Wednesday June 16, 2021 @11:28AM (#27529609)
So Stabel does not support (ad hoc) overloading, right? Will it support it?
Re:Stabel: A pure, concatenative and statically typed progra... by Skinney on Thursday June 17, 2021 @05:24AM (#27537719)
Right.

Not sure. Ad-hoc polymorphism is currently in the design-phase and I'm looking at many possible solutions. But before I get to that point I still have a lot of stuff to implement first.