On 02/07/2013, at 12:21 AM, srean wrote:

> 
> So it can be done. But then, all your HOF's and structs would
> just use generators to be most general .. and you might just as well
> not have the distinction.
> 
> I wouldn't know how to implement this,

I know how to implement it, its trivial to add a new function type.

The problem is that it creates a combinatorial explosion. Consider for
example a record of N functions, now we need 2^N record types
if each one could either be a generator or not.

As to impure functions: we could go further. Instead of just
saying 

        "this function depends on some variable"

we could say instead

        "this function depends on x and y"

That's even more precise. 

We could also just implement dependent typing which can capture
a lot of this kind of precision. I.e. I could make Felix generate ATS
instead of C++ (no need to actually do the type checking in Felix,
ATS will do it for us).

I am actually thinking about doing that.


> I am just trying to impress on you that these non-obvious subtleties that 
> might catch a program unawares should, as far as practicable be enforced by 
> the compiler.

I agree, but I impress on you that it isn't always so easy or even possible.
And many things that SEEM like a good idea aren't.

For example: Felix has uninitialised variables. Dobes didn't like this.
One could force the initialiser syntactically:

        var x: int; // ERROR

but it doesn't help:

        f x; // uses uinitialised variable
        var x = 1;

because Felix doesn't use linear scoping. It uses setwise scoping. Everything 
in a "scope"
can access everything else, the order is irrelevant.

But even if you could stop this, you end up with Ocaml: you have to initialise
a variable but if you don't have the value handy you just use a dummy value.
That's WORSE than an uninitialised variable. In Ocaml this happens with
arrays (you have to initialise an array when you create it).

In the end there's a simple observation: you cannot create a cycle
without an uninitialised variable. So you cannot create a graph.
[Interesting isn't it: functional languages cannot create cyclic
data structures, at least without closures, which is why lazy evaluation
is essential]

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




------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to