[Ecls-list] Simple Hello word! function

Louis Höfler louis.hoefler at gmx.de
Mon Jul 5 16:06:34 UTC 2010


Thank you for your help.

I used your code and implemented it.

 

cl_object string, stream, object, eof, evObj;

string = make_simple_base_string(srccontent);

stream = cl_make_string_input_stream(1,string);

eof = string; /* Marker for EOF */

do {

 object = cl_read(3, stream, Cnil, eof);

 if(object == eof)

  break;

 evObj = si_safe_eval(2, object, Cnil);

 cl_object princed = cl_princ_to_string(evObj); //Get output

 char* output = (char*)princed->base_string.self; //Convert the last result
to text

 ap_rputs(output, r); //Print out the last result to the client

 ap_rputs("\n", r);

} while (1);

 

If I run this lisp code:

(defun hello-world-two()

 (print "Hello world!")

 (print "How are you today"))

(hello-world-two)

 

It just prints out:

How are you today

 

While ECL itself prints:

"Hello world!"

"How are you today"

"How are you today"

 

Do I have to run the evaluated object

through a loop to get all output?

 

Von: Juan Jose Garcia-Ripoll [mailto:juanjose.garciaripoll at googlemail.com] 
Gesendet: Sonntag, 4. Juli 2010 19:33
An: Pascal J. Bourguignon
Cc: ecls-list at lists.sourceforge.net
Betreff: Re: [Ecls-list] Simple Hello word! function

 

The other option, which is not that bad, is to create a REPL for that
string.

cl_object string, stream, object, end;

string = make_simple_base_string(".....");
stream = cl_make_string_input_stream(1,string);
eof = string; /* Marker for EOF */
do {
  object = cl_read(3, stream, Cnil, eof);
  if (object == eof)
    break;
  ...
 si_eval...(object);
} while (1);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100705/484e5640/attachment.html>


More information about the ecl-devel mailing list