Friday, January 8, 2010

Hello Meta-PL/SQL, Hello M4O

Despite the temptation of playing with the APEX 4.0 preview, I used the winter holidays to clean up and finally publish an open source project. It's called M4O and implements a new programming language, Meta-PL/SQL, which is an extension of Oracle's PL/SQL. It features a simpler package syntax, aspect oriented programming and language extensibility.

Further information is available on http://code.google.com/p/m4o/.

Here's a teaser of what Meta-PL/SQL looks like:

@package-begin greeter_pkg
  @procedure hello_dbms_output*
    i_name in varchar2
  @begin
    dbms_output.put_line('Hello, ${nvl(i_name,'stranger')}!');
  @end

  @procedure hello_web*
    i_name in varchar2
  @begin
   <h1>Hello, <%=nvl(i_name,'stranger')%>!</h1>
  @end
@package-end

generates

create or replace package greeter_pkg as
  procedure hello_dbms_output(i_name in varchar2);
  procedure hello_web(i_name in varchar2);
end;

create or replace package body greeter_pkg as
  procedure hello_dbms_output(i_name in varchar2)
  is
  begin
  -- log that greeter_pkg.hello_dbms_output was called with   i_name
    dbms_output.put_line('Hello, '||nvl(i_name,'stranger')||'!');
  end;

  procedure hello_web(i_name in varchar2)
  is
  begin
  -- log that greeter_pkg.hello_web was called with i_name
    htp.p('<h1>Hello, '||nvl(i_name,'stranger')||'!</h1>');
  end;
end;

Please note that this is a very early release and a few planned features are missing. A previous version of Meta-PL/SQL has been in production use since summer 2008, however.

No comments: