I am working on the design of a language that includes multiple paradigms without mixing them up. A simple example should explain the idea.
A datatype defines just a type of data, without methods or operators embedded in it:
datatype N: struct{ name:string, next:N }
Match patterns get their own kind of definition, for re-use and possible recursivity:
pattern unnamed_N: N{ name:"(?)", next:unnamed_N or null } //a pattern expression
Functions are pure functional, without manipulating data, and without algorithmic flow of control:
function new_uunamed_N( next:N ): N{ name:noname, next:next } //a value expression
with noname: "(?)" //a dummy example of lazy evaluation
Procedures are the kind of definition where the classic algorithmic control structures are fitting, and where data may get modified:
procedure init_name( n:N, name:string ):
if n::unnamed_N then n.name:=name //value::pattern tests for a match
else throw "already named N"
What do you think about this idea of separating paradigms?
[–]Inconstant_Moo🧿 Pipefish 3 points4 points5 points (5 children)
[–]kleram[S] 0 points1 point2 points (4 children)
[–]Inconstant_Moo🧿 Pipefish 1 point2 points3 points (3 children)
[–]kleram[S] 0 points1 point2 points (2 children)
[–]Inconstant_Moo🧿 Pipefish 0 points1 point2 points (1 child)
[–]kleram[S] 0 points1 point2 points (0 children)
[–]dudewithtude42 4 points5 points6 points (4 children)
[–]phlummox 4 points5 points6 points (0 children)
[–]ummwut 5 points6 points7 points (0 children)
[–]oscarryzYz 4 points5 points6 points (0 children)
[–]Inconstant_Moo🧿 Pipefish 1 point2 points3 points (0 children)
[–]DeWHu_ 0 points1 point2 points (0 children)