[Ur] last type decl wins?
Vag Vagoff
vag.vagoff at gmail.com
Sat Apr 16 12:37:31 EDT 2011
> You're talking about this, correct?
>
> a = b
>
> b = a
>
> without a "and" ?
No, no!
just about
a = b
b = c
c = 0
> Am I right that a compiler could be made pretty printing a
> "implicit mutual recursion spread across files!"
> adding those "ands" for reading then?
Yes, exactly. Implicit mutual recursion must be regarded as error.
I'm not talking about recursive definitions at the moment.
> There are advantages to the Haskell way as ell.
> If you start moving functions for that reason only and start merging
> you won some time when reading - but you'll have a lot more trouble when
> merging..
>
> I don't expect there being a perfect way at all.
>
>> Being forced to choose different names for similar functions
>> with different scopes leads to longer and harder-to-understand names.
> May I conclude from that that urweb should support overloading? :)
I do not know -- there may be some issues with type checking/inferencing.
But if perfect language will be equipped with more mundane type system
it must support ad-hoc polymorphism by all means.
--------------------------------------------------------------------------------------
> Do you have some specific function names in mind which share a name but
> have slightly different behaviour?
No, but it is very easy to invent a dozen very realistic ones.
---- Coq ----
(* shadowing by argument (S) *)
Inductive Nat = Z | S Nat.
fold {A B S:Set} (f : A -> S -> S) (s : S) (xs : list A) : S := ...
---- Clean ----
// let-shadowing (f)
dowork f // # means "let before", as usual nonrecursive let but with silent shadowing allowed, excellent feature!
# (f,ok_flag) = writeFile "string" f // write a string to file
| not ok_flag = f
# (f,res) = readFile 13 f // read 13 characters from a file
| isJust res = fst (writeFile ("string2 " ++ fromJust res) f)
| otherwise = f
readFile :: Int *File -> (*File, Maybe String)
writeFile :: String *File -> (*File, *
---------- Haskell ---------
{- Shadowing top level names in local defs -}
import Prelude hiding (length) -- it is not about it
length :: [a] -> Int
length xs = length xs 0 where length [] n = n ; length (_:xs) n = length xs (n + 1)
main = putStrLn $ show $ length "hello, world!"
> would map and queryX be such cases?
Yes, perhaps.
Vag.
More information about the Ur
mailing list