On 22/08/2014, at 7:18 PM, john skaller wrote:

> 
> On 22/08/2014, at 5:44 PM, srean wrote:
> 
>> The syntax is too wordy :(
>> I would rather have an 'extra' ';' than all that finger typing.
> 
> Ok, noted .. I can do both actually :)
> Of course .. be nice to hear that from an actual user .. :)

How about:

        for (var i = 1; i < 10; ++i; ) println$ i;
        for (var i = 1; i < 10; ++i; ) { println$ i; println "blah"; };

The loop "body" is a single statement. The second case
is not special grammar, its already a single statement,
note the trailing ";" required after the "}".


Note this is very close to a comprehension.

Also note on another tack, this used to be possible:

        0 <= x < 10

which is equivalent to

        let ?v = x in 0 <= v and v < 10 

where the "let" ensures that the expression x only gets
evaluated once. I have disabled that at the moment.
Been thinking of this:

        { x | 0 <= x < 10 }

or more generally

        { x | P(x) }

which is the usual mathematical notation. In Felix { and } are
already used so some thought is required, \lbrace and \rbrace
look hard to type but they're TeX symbols. The left part of the
comprehension requires a type, consider:

        \{ x:int, y:int | x + y == 0 \}

The semantics are simple:

        \{ x:T | P(x) \} \cap \{ y: T | Q(y) }

just means

        \{ z: T | P(z) and Q(z) \}

and union, set difference, directed difference, subset etc etc
all follow: such sets are isomorphic to first order logic
(i.e logic with universal quantifiers at the head).


This is a bit more appealing to me for:

        \{ x:int | 0 <= x < 10 \}

because now the question of whether the range is inclusive or not
is well handled by the predicate.

Then we can allow

        for var i \in \{ x:int | 0 <= x < 10 \}

More generally, the set wouldn't have to be written literally.

However there is a problem!!! This only works for discrete ORDERED
sets and the concept that a set is just a NOUN standing for a 
VERB which is a logic operator (predicate) is lost.

So we'd need some way to distinguish a set as a comprehenion
of a predicate, from a set which is a comprehension from an
order.

By the way it is interesting that sets are also types in concept.
For example a regular expression represents a set of strings
which is a subtype of the set of all strings. So it makes sense to write

        var s : regexp "a.*b" = something;

and have that operation actually check that something is in the
denoted regular set. 

Of course this idea works best if you have dependent typing.
Still dynamic checks are better than nothing.

I'm still struggling for consistency here. Actually dislike the
C like use of { and } for blocks, would rather:

        proc f () 
                begin
                        stuff
                end

as in Pascal, so that the { and } can be used in a more mathematical way.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to