Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-09 Thread Thorsten
Alexander Burger  writes:

Hi Alex,

>> So maybe I should treat PicoLisp as a POSIX app and make my life easy
>> by just using "/dev/null" ;)
>> Would that be considered 'robust'?
>
> Indeed. I would say that this is a non-issue.
>
> IIRC, Cygwin supports "/dev/null", and otherwise PicoLisp doesn't run on
> MS-Windows anyway (except for the java version (ErsatzLisp)).

Thanks for your help. The C- and low-level stuff is a bit over my head,
and after all I've read in this thread, it really does not seem to be a
big issue. So I will just use (out "/dev/null" . prg), that should work
fine in almost all cases. 

Cheers
-- 
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Alexander Burger
On Sat, Oct 08, 2011 at 02:47:19PM +0200, Alexander Burger wrote:
> The Java-version (ErsatzLisp, "ersatz/pil") is special. It doesn't
> support the '*OS' global, and should run on any system where a 1.6 Java

Now I've changed ErsatzLisp to support '*OS' too, by adding the
following line to "ersatz/lib.l":

   (setq *OS (java (java "java.lang.System" "getProperty" "os.name")))

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Alexander Burger
Hi Thorsten,

> So maybe I should treat PicoLisp as a POSIX app and make my life easy
> by just using "/dev/null" ;)
> Would that be considered 'robust'?

Indeed. I would say that this is a non-issue.

IIRC, Cygwin supports "/dev/null", and otherwise PicoLisp doesn't run on
MS-Windows anyway (except for the java version (ErsatzLisp)).

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Alexander Burger
Hi Thorsten,

> > Perhaps it'd be easier to supply a hacked version of `out' on Windows,
> > made to recognized "/dev/null" as special case. Just like you can, for
> > example, use "/" as path separator in a lot of Windows apps.
> 
> I don't know C, but (without really understanding the code) I guess that
> somewhere in 'pushOutFiles' there must be inserted a 
> 
> ,---
> | if (OS equals Windows && any equals "/dev/null") {
> | ... send to "NULL" ...
> | } else { ... as is ...}   
> `---

Yes, you are on the right track :)

The problem is not really 'out' by itself, but all output functions
('print' etc.) probably called while the 'prg' body of 'out' is running.
The actual direction of the output stream is controlled on the lowest,
the character-output level. This is handled by the put() function, which
is actually a function pointer in the 'Env' environment.

> // from io.c
> ,
> | void pushOutFiles(outFrame *f) {   
> |OutFile = OutFiles[f->fd];  
> |f->put = Env.put,  Env.put = putStdout; 
> |f->link = Env.outFrames,  Env.outFrames = f;
> | }  
> `

The line

   f->put = Env.put,  Env.put = putStdout;

could set 'Evn.put' - instead of to 'putStdout' - to a do-nothing
function.

It might be tempting simply to set 'OutFile' to NULL in pushOutFiles().
You see that putStdout() does nothing if 'OutFile' is NULL. But this is
dangerous, as you may end up with a segmentation violation. 'OutFile' is
set to NULL in only a few special situations, e.g. when closing a file
descriptor asynchronously.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Thorsten
dexen deVries 
writes:

> On Saturday 08 October 2011 15:11:57 you wrote:
>> So maybe I should treat PicoLisp as a POSIX app and make my life easy
>> by just using "/dev/null" ;)
>> Would that be considered 'robust'?
>
> Perhaps it'd be easier to supply a hacked version of `out' on Windows,
> made to recognized "/dev/null" as special case. Just like you can, for
> example, use "/" as path separator in a lot of Windows apps.

I don't know C, but (without really understanding the code) I guess that
somewhere in 'pushOutFiles' there must be inserted a 

,---
| if (OS equals Windows && any equals "/dev/null") {
| ... send to "NULL" ...
| } else { ... as is ...}   
`---

for a hacked version of 'out'. Unfortunately, I'm not quite sure where,
and how to do that right in C. 

// from io.c
,---
| // (out 'any . prg) -> any
| any doOut(any ex) {   
|any x; 
|outFrame f;
|   
|x = cdr(ex),  x = EVAL(car(x));
|wrOpen(ex, x, &f); 
|pushOutFiles(&f);  
|x = prog(cddr(ex));
|popOutFiles(); 
|return x;  
| } 
`---
// from io.c
,
| void pushOutFiles(outFrame *f) {   
|OutFile = OutFiles[f->fd];  
|f->put = Env.put,  Env.put = putStdout; 
|f->link = Env.outFrames,  Env.outFrames = f;
| }  
`

Cheers
-- 
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread dexen deVries
On Saturday 08 October 2011 15:11:57 you wrote:
> So maybe I should treat PicoLisp as a POSIX app and make my life easy
> by just using "/dev/null" ;)
> Would that be considered 'robust'?

Perhaps it'd be easier to supply a hacked version of `out' on Windows, made to 
recognized "/dev/null" as special case. Just like you can, for example, use 
"/" as path separator in a lot of Windows apps.

-- 
dexen deVries

> It's called trolling. It's been done since there were bangs in people's 
email addresses.

thaumaturgy, on HN
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Thorsten
Alexander Burger  writes:

Hi Alex, 

> Yes, it is the global '*OS'. 

Ah, thanks. 

> As a general rule, "full" PicoLisp runs only on POSIX systems.

So maybe I should treat PicoLisp as a POSIX app and make my life easy
by just using "/dev/null" ;)
Would that be considered 'robust'?

But since quite a lot of people use Emacs on Windows, I should probably
take those two OS into account and ignore the rest. 

Cheers
-- 
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Alexander Burger
Hi Thorsten,

> depending on the OS. In elisp there is the variable 'system-name' to
> find out about the OS. Is there something similar in picolisp (I could
> not find anything)?

Yes, it is the global '*OS'. Its value is determined at build-time, from
the variable 'OS' in "src/Makefile" or "src64/Makefile". In these files
you can also see the possible values.


> On which OS is picolisp running currently, I read quite a lot of post
> about porting it to other OS here recently.

As a general rule, "full" PicoLisp runs only on POSIX systems.

Primarily, it runs on Linux. This was the initially supported platform.

The 32-bit version also builds and runs under MS-Windows on Cygwin (with
some limitations).

The Java-version (ErsatzLisp, "ersatz/pil") is special. It doesn't
support the '*OS' global, and should run on any system where a 1.6 Java
Runtime Environment is installed. ErsatzLisp also has some limitations
(see "ersatz/README").

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-08 Thread Thorsten
Randall Dow  writes:

> Windows has the "NUL" (or is it "NULL") device.

so I might define a function 'no-out' that calls either

 ,---
 | (out "/dev/null". prg)
 `---

or

 ,--
 | (out "NULL". prg)
 `--

depending on the OS. In elisp there is the variable 'system-name' to
find out about the OS. Is there something similar in picolisp (I could
not find anything)?

On which OS is picolisp running currently, I read quite a lot of post
about porting it to other OS here recently.

That inhibition of any writing to STDOUT should basically work on all
platforms that support both - emacs and picolisp. 


> On Oct 8, 2011, at 5:13 AM, Thorsten wrote:
>> I need a way to inhibit any writing to STDOUT in a PicoLisp codeblock. I
>> found the following, what seems to work just fine on Linux: 
>> 
>> ,
>> | (out "/dev/null" . prg)
>> `
>> 
>> But what about Windows and other platforms (without /dev/null)? Is there
>> a generic, platform-independent way to achieve the same thing? 

Cheers
-- 
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Inhibit any writing to STDOUT in PicoLisp codeblock

2011-10-07 Thread Randall Dow
Windows has the "NUL" (or is it "NULL") device.

--
Rand

Sent from Macbook Air

On Oct 8, 2011, at 5:13 AM, Thorsten wrote:
> I need a way to inhibit any writing to STDOUT in a PicoLisp codeblock. I
> found the following, what seems to work just fine on Linux: 
> 
> ,
> | (out "/dev/null" . prg)
> `
> 
> But what about Windows and other platforms (without /dev/null)? Is there
> a generic, platform-independent way to achieve the same thing? 
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe