[clean-list] Re: Really Newbie Question about loops/input

Siegfried Gonzi siegfried.gonzi@kfunigraz.ac.at
Tue, 02 Oct 2001 11:19:59 +0200


Jay Kint jean-luc-picard@ussenterprise.com schrieb:

==
Here is the source code so far:

getCommand :: !*File -> String
getCommand console = fst (freadline (fwritec '>' console))

commandLoop :: !*File (*File->String) -> *File
commandLoop console get
    = commandLoop (fwrites ((get console) +++ " ")
         console) get

Start :: *World -> *File
Start world
 # (console,world) = stdio world
 = commandLoop console getCommand

Trying to compile this I get:
"Type Error [116,commandLoop]:"get" * attribute required but not offered
at
the indicated position: ^ File
==

I think this points to the fact that the file access is not unique (the
"*" marks uniqueness in Clean). This error message in Clean can one
drive crazy, because it is not co-operative when debuging.


>First of all, what does the error message mean?  What does the "* attribute
>required" but not offered mean when in fact I have a function that takes the
>exact parameter types its looking for (or so I think).

Try to write the function "commandLoop" with one occurence of "!*File"
only. I would say that passing "getCommand" to commandLoop and also
passing a console-file type can maybe cause the trouble.

On the other side: I am not sure why do you in:

= commandLoop console getCommand

pass "getCommand" without a file name, because you defined getCommand:

getCommand :: !*File -> String

>Second of all, what does the "^ File" at the end of the error message mean?
>Is there an operator "^"?  I haven't seen it mentioned to date.

Do not bother about the "^" sign. Maybe it has got some deeper meaning
but for your (and my) case it is not worth to care. The "*" indicates
the uniqueness in Clean. Normally you may not make a file unique when
you want to read from it; it is even possible that two functions read
from the same file. But if you want to write to a file, with the unique
information you make sure that at the time when writing, that there are
only *one* file access at that time. The "*" also shows up at arrays. In
Clean you can make destructive array updates. This is of great
advantages, when speed is a criterion, because destructive array update
does not have to copy arrays and therefore slows down the array
handling.


S. Gonzi