Monday, March 11, 2019

The "main" Question...a Question of Ambiguity in Language Design

A design question in Zepton is when a user defines a method "static void main(String[] args)" which in Java is the main method. The problem is Zepton uses a do-block as the implicit main method, or the program body.

So the question is how to handle this ambiguity? Which is the progam main method, and if a user writes it, how does the compiler handle it? There is a main method, which in Java is where execution begins, and the program do-block, which is where execution begins in Zepton.

Example "helloWorld.zep" code:

package zepton.demo;

prog helloWorld {

  static void main(String[] args){

    println("Hello World!!!");
    exit(0);
  }

do

  println("Hello World!!!");
  exit(0);

}

This is an example of Java semantics and syntax versus Zepton semantics and syntax. But a concern is the cognitive dissonance caused when "main" is used in Java, versus how it is handled in Zepton.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.