Re: PHP

From: Christophe Turle (cturle_at_nospam.fr)
Date: 03/24/04


Date: Wed, 24 Mar 2004 11:36:28 +0100


> Do you mean you have tools or know about tools, who translate Lisp
> programs into php?
> This would be very funny, because I have to do a good amount of php at
> work and I don't think I can't convince the project manager to switch
> over to Lisp (cause already several hundred php scripts are working in
> this project and the other programmers don't know about Lisp).
>
> But with your trick I could probably write at least some of the scripts
> in Lisp and let them be translated into php.

The trick is no more than meta-programming. I try to define some application-related knowledge using lisp. Then my lisp functions write some target code. The goal is not to have a conversion program. The goal is to have a program which have knowledge about different language. it is a long term goal and i'm far from having showable results. The only general thing i have is a tool to include meta-code into source files.

here's an example :

; file generated by an idl to C++ compiler

...

// begin-asgard-code (snc-method-definitions-of-corba-object "PC-GraphEH" )

; all the code below is generated automatically from the evaluation of the expression : '(snc-method-definitions-of-corba-object "PC-GraphEH" )'

void CorbaObject::added_ERport (
  const char * ERportId
)
ACE_THROW_SPEC ( ( CORBA::SystemException ) )
{
  cout << "--> GraphEH::added_ERport(" << " ERportId='" << ERportId << "'" << " )" << endl ;

  NodeId lv_ERportId = static_cast< NodeId > ( ERportId ) ;

  // begin-user-code (app-code (corba-c++:c++-method (FIND-CORBA-SERVICE (FIND-CORBA-OBJECT "PC-GraphEH") :NAME "added_ERport")))

  ; we can't generate all code automatically. begin-user-code allows us to insert user code.
  ; all code here is 'setf' to the expression
  ; (app-code (corba-c++:c++-method (FIND-CORBA-SERVICE (FIND-CORBA-OBJECT "PC-GraphEH") :NAME "added_ERport")))
  ; which should be used at this space during the generation process.

  mr_msn.add_ERport( lv_ERportId ) ;
  // end-user-code
}

...

// end-asgard-code
...
; end-of -file

; file snc-corba.lisp

...

;;; surely i can generate this from the idl file using clorb.

(def-idl-interface
  :name "GraphEH"
  :operations ( (:name "added_ERport" :args ((:type NodeId :name "ERportId")))
                 ... ))

...

(def-corba-component :abbrev "PC" :name "pathControler")
(def-corba-object :component "PC" :idl-interface "GraphEH" )

...
;end-of-file

This way, all codes in any source file, i can generate automatically is. I just need to (update-files).

(author "Christophe Turle" :nickname "ctu")



Relevant Pages

  • Re: Python gets macros - now XML does too
    ... >>final target language of choice. ... Currently PHP, Java, and Perl are ... > What you called level 2 metaprogramming is possible in Lisp, ... of business in 1994 and that marked the end of the Amiga computers era, ...
    (comp.lang.lisp)
  • Re: Python gets macros - now XML does too
    ... >> use LISP macros to generate code in another language, say PHP, Java, ... > bytecode, PHP is simple. ...
    (comp.lang.lisp)
  • Re: Lisp anxieties
    ... > some experienced Lispers thought of the PHP language. ... Will lisp be able to handle that sort of load without me having to ... it does it better than java.) ... other forced organizations based on platform, ...
    (comp.lang.lisp)
  • Re: PHP and LISPPA technology
    ... think that implementation LISP in PHP is a good idea because nested ... > reason why you couldn't do the same in php. ... > interpreters in LISP, this may have complicated things quite a bit. ... trees and other dynamic data structures directly in PHP. ...
    (comp.lang.php)
  • Lisp anxieties
    ... some experienced Lispers thought of the PHP language. ... I know what Lispers will say about PHP. ... Will lisp be able to handle that sort of load without me having to ...
    (comp.lang.lisp)