Scriptor / pharen

Lisp to PHP Compiler
http://pharen.org
BSD 3-Clause "New" or "Revised" License
218 stars 31 forks source link

Defining namespaces break compilation inside macros #48

Closed girvo closed 11 years ago

girvo commented 11 years ago

Hey there.

I'm currently writing a simple project definition and module definition macro in lang.phn

The idea is to encapsulate modules inside their own namespaces (or perhaps as subnamespaces of the Pharen\Module ns that I'm creating).

The ns function defined in Pharen.php seemed to be the ticket (along with the load macro and use function, however when I define a macro that uses ns it gives the following error at compile time:

PHP Fatal error: Call to undefined method stdClass::compile() in /var/pharen/pharen.php on line 1089

The macro definition that causes this is as follows:

(defmacro defproject (name version)
    '(ns ~name)
    )

This macro when compiled (linked using load macro) generates this PHP:

<?php
    namespace ;
require_once('/var/pharen/lang.php');
use Pharen\Lexical as Lexical;
Lexical::$scopes['api'] = array();

I believe it's that empty namespace that is being generated there that is causing the issue.

Any ideas?