View Single Post
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 02-20-2013, 07:11 PM

Functions answer questions.
This leads to two points.
  1. Functions return values. The value that is returned depends on the function. Something like "isAbove" will return a Boolean, one object is either above the other or its not. A "distance to" function will return a number. In both cases the function is answering a question. What a function should NEVER do is change the world. If you have a function which asks if the spider robot's head is red, it should return True or False, but the function should not changes the robots head color, just report on its value.
  2. To use a function in Alice, the place where the function is dropped must be looking for an answer of the type the function provides. For instance the if part of an "if/else" statement is looking for a Boolean value. That means we either need to supply a function that returns a Boolean value or we need to use something like a comparison operator. These operators take two numbers and return a Boolean. Another example would be the move instruction, which will take any function that provides a number.

Mark
Never use absolutes, they are always inappropriate, there is never a case that does not have an exception, never use absolutes.

(From an English Professor I took a class with)
   
Reply With Quote