On 10/1/07, skaller <[EMAIL PROTECTED]> wrote:
> My turn next .. been reading the Ruby docs .. so I can understand
> your weird
>
>         (1,2,3).foreach { |i| print i }
>
> stuff. Well, the doc explains this isn't what I thought it was:
> in fact, the LHS and RHS are coroutines.
>
> So actually, what you wanted to do is better described by the idea
> that |i| is a channel, and the LHS and RHS are fthreads/fibres.

I don't think they really are coroutines, even though they use yield.
After a little playing around with irb, yield *only* passes the value
to a block. I don't see how this isn't sugar  for just not specifying
a function takes a lambda. So, ruby doing this:

def foo
  yield 5
end
foo { |x| puts 5 }

Is really just equivalent to:

proc foo (f:int->unit) {
  f 5;
}
foo $ proc (x:int) { println x; };

There's no real concept of things happening concurrently as far as I
can see. Now, we don't have to copy what ruby and we could make { |x|
... } be sugar for fthreads, but I think I'd rather refer to erlang
for inspiration.

> No, you only need to open Str, the typeclass. If the method str has
> type T, the type of the typeclass, lookup will work for any type T,
> even if there is no instance. If there is no instance, it will fail
> later during instantiation.

I didn't know that that's all you needed to do. Now I think I
understand why my "open instance" was wrong. So, since "typeclass
Foo[T] { ... } open Foo;" works, should we add support for "open
typeclass Foo { ... }"?

> To do that, you need a way to iterate something over the
> tuple. I tried flatten and other things but here is the go:
>
>         pile_right : t1 * t2 * t3 ... tn ->
>                 t1 * (t2 * (t3 * .. (tn * ()))) ..)))
>
> Every element is a pair of a single type on the LHS, and
> another pair on the RHS, except the sentinel ().
>
> Which is clearly a list and will allow recursion like:
>
>         fun str[T with piled[T]] =
>         | ?h, ?t => str h + ", " str t
>         | () => ""
>         ;
>
> where the call 'str t' above is polymorphically recursive
> (calls the same function but with different type arguments).

Yes I'm aware of that problem and it's great to hear you might have a
solution to it. When I first made the Str typeclass, I copied what
Haskell does and hardcoded instances of a tuple with up to 12
different types. It was really ugly so I didn't add it. I hope what
you can propose can do this for any number of types.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to