[clean-list] Help Please: Beginner to Clean.. Console I/O‏

Khurram Khan kkjcid at hotmail.com
Mon May 2 20:42:56 MEST 2011


Hi

I have previously been in touch with someone regarding 
some issues I am facing learning programming in Clean. He recommended 
that I should read CleanBook1, (http://wiki.clean.cs.ru.nl/Functional_Programming_in_Clean),
 which i did. However, I am still not fully satisfied with my 
understanding of I/O commands in Clean. I was able to completely 
understand Chapter 1-2-3 and some parts of Chapter 4 as well, I have 
also completed all the exercises which came along the first three 
chapters. 



Now if we consider the example "hello1" from the CleanBook1, chapter 5.1.1



Start :: *World -> *World

Start world

    # (console,world) = stdio world

    # console = fwrites "What is your name? " console

    # (name,console) = freadline console

    # console = fwrites ("\n\nHello " +++ name) console

    # (_,console) = freadline console

    # (ok,world) = fclose console world

    | not ok = abort "Cannot close console"

    | otherwise = world


then it first prints a string (using fwrites) to the console and then 
reads a line (using freadline) from the console. but I find it hard to 
understand the meaning of each line of the code. For example: 


Code Line 1   - why does we write (console,world) in the first line of the code?

Code Line 3   - is the line read from the console stored in "name"? is 
"name" a variable or an list/array, and can we perform any operation on 
it before printing it back to the console?

Code Line 5   - in (_,console) what does "_" represent

Code Line 6   - What does (ok,world) mean?



Question regarding output of the above program: When i compile this 
program in Clean then it prints out the value 65536 on the console at 
the end, before terminating. What does this value represent and why is 
it output? because i am not able to understand where it comes from as it
 is not mentioned anywhere in the code.



I will be deeply grateful for any help on this matter.



Kind regards

Khurram 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/clean-list/attachments/20110502/54a0f961/attachment.html>


More information about the clean-list mailing list