Closed mrbloom closed 11 years ago
can you show also the pharen file?
I copied a code from tutorial
; pastebin/new.phn (require "sql.php") (require "html.php")
(fn print-paste-link (id) (print (html-link (. "/pastebin/paste?id=" id) "New paste")))
(fn print-paste-form () (print (html-form "post" ($ server "PHP_SELF") (html-textbox "title") (html-textarea "contents") (html-submit "submit"))))
(sql-connect "your-username" "your-password" "pastebindb")
(if (isset ($ post "submit")) (print-paste-link (sql-insert "pastes" {"title" ($ post "title"), "contents" ($ post "contents")})) (print-paste-form))
The tutorial is very out of date and much of it won't work at all, with all the additions to the language. I'd suggest reading through the reference and getting a feel for the language features. There is also the beginning of a Four-in-a-Row game, which you can skim to get an idea of what Pharen code looks like.
I took example from the reference. What i did: pharen sql,phn html.phn new.phn
I've got sql,php html.php new.php
When i comment in sql,php html.php //use Pharen\Lexical as Lexical; //Lexical::$scopes['sql'] = array(); and //use Pharen\Lexical as Lexical; //Lexical::$scopes['sql'] = array();
new.php works. I think, the problem is that compiled new.php doesn't know about namespace of the sql and html library functions
This example doesn't work on php 5.3 under Ubuntu. i can compile it to new.php. But it starts to work only if i comment in html.php
//namespace pharen\html; //require_once('/home/mrbloom/pharen/lang.php'); //use Pharen\Lexical as Lexical; //Lexical::$scopes['html'] = array();