Scriptor / pharen

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

Form handling - example from Quick Tutorial #52

Closed mrbloom closed 11 years ago

mrbloom commented 11 years ago

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();

francescoagati commented 11 years ago

can you show also the pharen file?

mrbloom commented 11 years ago

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))

Scriptor commented 11 years ago

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.

mrbloom commented 11 years ago

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