Why was serialEvent() added to Arduino 1.0?

What is the reason for serialEvent() in Arduino 1.0 beta 4?

It doesn't run at interrupt level so it seems equivalent to adding the following to loop() by a user.

  if (Serial.available()) serialEvent();

It's not a big deal but I am curious why this was done.

I believe it was added to make the Arduino language more Processing-like.

Even though Developer's List email does not always make it into Google this may help answer the question...
http://www.google.com/search?q=serialevent+site:arduino.cc%2Fpipermail&btnG=Google+Search

Looks like is started as a call from the Serial RX ISR at interrupt level but has evolved to a call from main() between calls to loop().

It is now a more or less useless addition. At least it is small and won't burn too many CPU cycles.

My interpretation is that this is addressed toward the many questions of the form "how do a deal with a multi-character comand string coming from my serial port." Using the "serialEvent", you get to define a sort of secondary process that assembles the individual bytes received into bigger chunks that the sketch can use more logically, without having to distract the loop() code from the core functions. Think of Serial as being the low-level device driver, and serialEvent being the mid-level "tty driver" (that might provide line mode with echoing and editing, for example.)

It's not clear exactly how it will be used, but it's at least potentially far from "useless"...

It's not clear exactly how it will be used, but it's at least potentially far from "useless"...

I rest my case. So far only speculation that it might have some unknown use.

serialEvent() is not an asynchronous event, It happens right after you exit loop(), not when a character is received. This means it is equivalent to adding a call at the beginning of loop(). A function call in loop() could be cleaner since it could return status.

Show me an example where serialEvent() is a big improvement over adding a single line at the beginning of loop() that calls the user's function for processing Serial input.

My speculation is that serialEvent() was invented to add two usec between loop calls on a 328 and six usec between loop() calls on a Mega. This seems fairly harmless.