Re: [pure-lang-users] Proposed syntax changes
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-08-15 11:57:52
|
Jeremy Voorhis wrote: > OMG $$++ That gives me a syntax error. ;-) But look at this marvel! > OMG = id; > OMG $ (Im,feeling,silly)!2 $ OMG ponies; silly ponies Ok, I take it that $$ is the consensus. > Regarding tuples, I've always thought of tuples as representing > structures with a fixed number of slots, and that this was a perfectly > valid thing to do. That's what they are, but Pure also allows you to piece them together and manipulate them in any way you see fit. Also, in Haskell et al tuples are a builtin data structure, whereas in Pure they are just an algebraic type like any other (and are in fact completely defined in the prelude). > My Pure abilities are still weak, so somebody help > me out – I assumed tagged tuples would be useful for representing > algebraic types in a dynamic language like Pure, since they are good > for matching on. That's what poor Erlang programmers have to do. In Pure all your data is in fact a term algebra, so any function symbol can act as a constructor and you don't need this kludge. E.g., nil and bin act as constructors in the following example: nullary nil; insert nil y = bin y nil nil; insert (bin x L R) y = bin x (insert L y) R if y<x; = bin x L (insert R y) otherwise; (That works without having to declare anything, except a nullary symbol like nil so that the compiler can distinguish it from a variable when it occurs on the lhs of an eqn.) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |