Alexis Lee alexis@turton.com writes:
Yes, but just what can you _do_ with a function except rewrite it or call it? Function division and subtraction?!?
If you like. Personally, I tend to use them in catch statements and other such things. Thunks are often handy, too.
All the rewriting you might want to do deals with a function as a piece of text, and thus is better dealt with using existing string functions plus eval(). Not quite as syntactically pretty, but it does mean you're not duplicating the string library.
Functions aren't strings! Think about manipulating their parse structure trees in a similar way to XSLT manipulating XML trees. No, I don't do that quite so much with variables, but macros are powerful tools.
Yes, but the power comes if you don't do bad cohesion like that and you compose functions. I very rarely use begin... The time when I do is when I'm trying to interface with something procedural, such as a database.
hum, I understood you were meant to start your program with a begin. I guess that's just a useful thing to do.
No, I hardly ever use it. You only start your program with begin if you're making the popular mistake of writing procedural code, I think. My recent programs (in guile) consist of a use-modules line, then a single structure.
We-know-who-we-are sizzled:
If you like. Personally, I tend to use them in catch statements and other such things. Thunks are often handy, too.
Um... Java catches let you specify a block anyway. Arguments have to be passed via a custom Exception object, but arguably that's good OO- encapsulate the exception scenario. And if you need to handle different Exceptions, you specify extra catches and hence blocks. Whassa thunk, other than a rather satisfying sound?
Functions aren't strings! Think about manipulating their parse structure trees in a similar way to XSLT manipulating XML trees. No, I don't do that quite so much with variables, but macros are powerful tools.
I stopped when I got to the macro chapter ;-)
When I write a function, I like to forget how all the functions it calls work, and to an extent what the caller wants. If I have other functions all bound up in this one, I can't forget about them.
It seems to me that if you don't write procedurally (ie bunch of defines then start calling them), you have to define your functions every time you use them. Or at least per scope you use them in, in which case you're rather likely to end up with global defines again.
No, I hardly ever use it. You only start your program with begin if you're making the popular mistake of writing procedural code, I think.
I appreciate that. The tutorial at cs.rice.edu does it, which is why I assumed it was standard practice.
Would it be possible for you to send me one of your (use-modules (...)) (...) programs? Ideally a medium-sized one, or the issues we're discussing won't come up very noticeably.
Just incidentally, cause presumably you'll be replying anyway, is it OK to use {} instead of () sometimes? Bet it isn't, but I haven't seen them used for anything yet, and it gets very difficult to follow lots of irritating silly parentheses.
Alexis