On Fri, Aug 17, 2012 at 7:31 PM, john skaller <skal...@users.sourceforge.net
> wrote:

>
> On 18/08/2012, at 6:19 AM, Dobes Vandermeer wrote:
> >
> > What are you saying, is that your internal representation makes it
> difficult or impossible.  However, this isn't the only representation
> available, so really what you are saying is that you don't want to change
> your representation.
>
> If you want to avoid this problem you can use the functional
> constructions such as
>
>         let ?x = expr in
>
> where you cannot refer to x until after it is initialised.
>

RIght - just treat every var ... and val ... as if it is opening a new let
starting at that point and continuing to the end of the block it is in.
 This isn't rocket science.


> Things get more difficult if you have conditional gotos, as I'm
> sure you can imagine, you have to prove there is no control path
> which could initialise a val prior to a use before issuing a diagnostic.
>

It's not too late to get rid of goto, is it?

One can be conservative in the presence of goto and labels - which label
you are jumping to is always hard-coded so you can simply check whether it
is even remotely possible a var or val is not initialized and ban its use
at any point after the label.  The use of gotos should be so rare that this
should impact almost nobody.


> In C++ the rule is "you cannot jump past an initialisation".
> But C++ has blocks. Felix does not. Felix does have nested functions
> which work like blocks when called but they're not quite the same,
> because you cannot "return" from the main function from inside
> the nested one. Nor can you yield. You can jump out though.
>

Are you saying you cannot do

fun foo() = {
if X then do
   return Y;
done
return Z;
}
?


> > I guess performance isn't THAT important to me.
>
> Oh yes it is, it is the ENTIRE reason for using computers!
>

I meant I won't sacrifice the predictability of me code on the alter of
performance.

You were justifying your solution where the runtime behavior of my
application depended on decisions made by the optimiser (whether to inline
or not).  That's not a worthwhile trade-off.


> > Lexical ordering seems relatively simple to me, maybe I'm missing
> something:


> Felix doesn't use lexical ordering for lookup. So the check has to be done
> after lookup.
>
> Define before use does not support recursion.
>

This need only apply to vals and vars, functions can be recursive.
 Recursive vals are just a confusing oddity... when I saw that in Scala I
was like "WTF?" They are in enough of a bubble to think this is kind of
cool, I think it's kind of a hole in the bottom of the boat.


> > I guess what you are referring to is that if you divide by zero the
> program may crash or throw an exception.
>
> What I'm saying is that if you write:
>
>         if divisor == 0 then 1 else dividend / divisor endif
>
> does not crash **because** the second and third arguments are lazily
> evaluated. In C:
>
>         divisor == 0 ? 1 : dividend / divisor
>
> You cannot write this function as a function because it is lazily
> evaluated in C,
> and function arguments are eagerly evaluated.
>
> There is a wide class of functions where it makes no difference if the
> arguments
> are eagerly or lazily evaluated, and "val" supports that. Nice functions
> like "sin" just don't care.
>

In C you know that ?:, &&, and || are lazily evaluated, though.  I don't
like to be told that, for example:

fun maybe_div(x:int, y:int) = {
   val result = x/y;
   return if y == 0 then None[int] else Some result endif
}

May or may not trigger a DIVBYZERO error depending on the optimizer's
decisions at compile time.  I don't want this function to work perfectly
for years and then one day, due to some little optimizer tweak or someone
exceeding the inlining threshold, it starts causing the program to abort.

That's just not what I would consider a "safe" programming language.

It increasingly appears that you have little interest, however, in safety -
your interest in types stems only from an interest in performance.

Unfortunately I myself am interested in safe programming; I have enough
trouble finding bugs I created without the optimizer throwing in a few of
its own.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to