[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Sun, 25 Apr 2004 17:20:06 +0000 (UTC) 
Subject:Re: new problem: speed declines very much 
From:A . Sloman 
Volume-ID: 


On Sun, 25 Apr 2004, Fatemeh wrote:

> Thank you very much.
> I tried â??syscreateâ??, â??syswriteâ?? and â??syscloseâ?? but it  had error at
> â??syswriteâ??. I did as the following:
> Vars I=num;
> Syswrite(dev,I,2);

I would need to be a string, and dev would have to have been produced
by sysopen for that to work.


> I think, I should not give â??Iâ??(I tried â??datakey(I)â??, also).

I don't think that would help. Unless you are thinking of datafile
which would be relevant only if you were saving structures containing
structures other than lists vectors words, strings and numbers.

> I don.t have any
> time for read REF DATA about datastructures and understanding them. For this
> reason, I tried â??discoutâ?? but there is error. I did as the following:
>
> define f(n);
>  n*2=>
> enddefine;
> define global vars save(file, proc);
>      lvars file proc;
>      dlocal cucharout = discout(file);
>      proc();
>      pr(newline);
>      cucharout(termin)
>  enddefine;
>  save(â??filenameâ??,f(4));
>
> What is problem?

The second argument of save has to be a procedure.

When you type

    f(4)

as the second argument, you RUN the procedure f, with the input 4.
It prints something and returns no result.

All of that happens *before* save runs.

In Pop11, as in Forth:

    save('filename',f(4));

is equivalent to

    'filename', 4, f(), save();

You want the second argument for save to be something that refers to
a procedure.

In that case you can create a procedure by combining f and its argument
into a closure, using 'partial application'.
(See HELP closures, HELP partapply)

This syntax
    f(%4%)

means create a new procedure which when it runs will apply f to 4.
More precisely: it will put 4 on the stack, on top of anything already
there, and then run f().

So you can use this format to give save that procedure as its second
argument:

    save( 'filename', f(% 4 %) );

(I have added some spaces for clarity. They are not required.)

That is equivalent to

	'filename', f(% 4 %), save();

Aaron