Pitfalls

From IokeWiki
Revision as of 20:14, 26 January 2009 by Olabini (talk | contribs) (New page: This page collect easy mistakes to do while developing Ioke code. Anything that causes unobvious failures should be listed here. Note that things on this page are not bugs - just things th...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page collect easy mistakes to do while developing Ioke code. Anything that causes unobvious failures should be listed here. Note that things on this page are not bugs - just things that might be a bit counterintuitive at first glance.

Mismatched commas

One of the most insidious problems that can show up in Ioke programs happen when you forget to add a comma at the right place - or add a comma in a place where there shouldn't be one. Remember, commas separate arguments. Nothing else. Here are some of the most common situations where a mismatched comma will cause the program to work incorrectly - but it will generally still run.

Missing comma after documentation text

When defining a method, macro or syntax with a documentation text, it is very important to remember to add a comma after the text. In most cases the only thing that happens when you forget it is that the object will not get any documentation. But if you continue the expression on the same line you will probably get a signaled condition of some kind.

An example of faulty code:

foo = method("foo is a method that does something really cool"
  42*42)

Fixed version:

foo = method("foo is a method that does something really cool",
  42*42)

The most problematic case is when you have arguments. In that case the omission of the comma will lead to incorrect code that will fail at some point:

foo = method("foo is a method that does something really cool" x,
  42*x)

When foo is called above, you will get either a Condition Error Invocation TooManyArguments, or you will get a Condition Error NoSuchCell. The solution is easy:

foo = method("foo is a method that does something really cool", x,
  42*x)

Missing comma in case, cond, if and unless expressions

Added comma in dmacro specification