Michael Sperber | 7 Apr 2008 17:53
Picon

Re: Converting scheme48 to a socket repl problem


Andrew Lentvorski <bsder <at> allcaps.org> writes:

> [running Scheme 48 off a socket]

I've had another look at this: I don't know what you're trying to do
exactly, but if you apply the attached patch (nothing fancy; just makes
the `usual-commands' package visible, rebuild via "make image", and do
this:

,open command-processor package-commands-internal big-sockets i/o

(define (repl)
  ((new-command-processor "Hello! Don't eat that yellow snow!"
			  (get-structure 'usual-commands)
			  (get-structure 'built-in-structures)
			  (get-structure 'more-structures))
   '()))

(define (scheme-server)
  (let ((socket (open-socket 8888)))
    (call-with-values
	(lambda ()
	  (socket-accept socket))
      (lambda (in out)
	(with-current-ports
	 in out out
	 repl)))))
	   
... you get a one-off server you can connect to which will give you a
(Continue reading)

Andrew Lentvorski | 8 Apr 2008 14:26

Re: Converting scheme48 to a socket repl problem

Michael Sperber wrote:
> Andrew Lentvorski <bsder <at> allcaps.org> writes:
> 
>> [running Scheme 48 off a socket]
> 
> I've had another look at this: I don't know what you're trying to do
> exactly, but if you apply the attached patch (nothing fancy; just makes
> the `usual-commands' package visible, rebuild via "make image", and do
> this:
> 
> ,open command-processor package-commands-internal big-sockets i/o

What is big-sockets?  It seems like I can just replace that with sockets.

Otherwise, yes, this is exactly what I was looking for.

Now, my final issue is cracking open a top-level loop in order to call 
into an external hardware handling system.  My current searches seem to 
indicate that one place to hook in is s48_wait_for_event.  However, that 
only works if the system actually goes and waits for an event.  If the 
system is in a tight loop doing computation, it's not clear that will 
get called in a timely fashion.

After quite a bit of digging, it looks like the place to break in is in 
the "(define (interpret code-pointer))" function in interp.scm. 
Presumably, I can count the number of dispatches through here and 
interrupt after some number.  Basically, I would like to jump out to a C 
function "handle_hardware_housekeeping()" after the VM executes 100-150 
opcodes.

(Continue reading)

Michael Sperber | 9 Apr 2008 08:07
Picon

Re: Converting scheme48 to a socket repl problem


Andrew Lentvorski <bsder <at> allcaps.org> writes:

> Michael Sperber wrote:
>> Andrew Lentvorski <bsder <at> allcaps.org> writes:
>>
>>> [running Scheme 48 off a socket]
>>
>> I've had another look at this: I don't know what you're trying to do
>> exactly, but if you apply the attached patch (nothing fancy; just makes
>> the `usual-commands' package visible, rebuild via "make image", and do
>> this:
>>
>> ,open command-processor package-commands-internal big-sockets i/o
>
> What is big-sockets?  It seems like I can just replace that with sockets.

Yes; it will be called `big-sockets' in the future (and already is in
the development repo), as the sockets are being replaced.

> Otherwise, yes, this is exactly what I was looking for.

Excellent!

> Now, my final issue is cracking open a top-level loop in order to call
> into an external hardware handling system.  My current searches seem
> to indicate that one place to hook in is s48_wait_for_event.  However,
> that only works if the system actually goes and waits for an event.
> If the system is in a tight loop doing computation, it's not clear
> that will get called in a timely fashion.
(Continue reading)

Ivan Shmakov | 15 Apr 2008 11:16
Picon

configure.in: Move some `AC_SUBST's to *.m4

	May I suggest the following patch?

	This one shouldn't affect `configure', except for the order of
	entries in `ac_subst_vars' and in the Sed's substitutions
	template.  Some empty lines may change their positions within
	the file as well.

# HG changeset patch
# User Ivan Shmakov <ivan <at> theory.asu.ru>
# Date 1208245265 -25200
# Node ID 669986d56492f19720b9d3268dc45153ba926908
# Parent  75afd5d97a66f49e48c84654f548ca7b86e20dd4
Split some `AC_SUBST's off `configure.in' into the respective `m4/' files.

configure.in: Moved the `LDFLAGS_VM' substitution...
m4/s48_ldflags.m4 (S48_LDFLAGS): ... here.

configure.in: Moved the `ASM_OBJECTS' and `ASM_STYLE' substitutions...
m4/s48_native_code.m4 (S48_NATIVE_CODE): ... here.

configure.in: Moved the `S48_GC_TWOSPACE' and `S48_GC_BIBOP'
substitutions...
m4/s48_pick_gc.m4 (S48_PICK_GC): ... here.

diff -r 75afd5d97a66 -r 669986d56492 configure.in
--- a/configure.in	Wed Apr 09 08:43:20 2008 +0200
+++ b/configure.in	Tue Apr 15 14:41:05 2008 +0700
 <at>  <at>  -107,15 +107,10  <at>  <at>  dnl POSIX says it's `environ'.
      AC_SUBST(CFLAGS)
      AC_SUBST(LDFLAGS)
(Continue reading)

Ivan Shmakov | 15 Apr 2008 17:32
Picon

minor fixes

>>>>> "IS" == Ivan Shmakov <ivan <at> theory.asu.ru> writes:

[...]

 IS> Some of the changes (minor bug fixes) probably may be useful
 IS> outside of the scope of the MinGW compilation.  (Check
 IS> c/fake/sysexits.h, and Makefile.in for CPPFLAGS, for example.)

[...]

	Oh, these issues are still there.

	BTW, what about the CPPFLAGS change?

diff -r 43f2807b79eb Makefile.in
--- a/Makefile.in	Sun Jan 27 18:33:32 2008 +0600
+++ b/Makefile.in	Fri Feb 01 21:15:32 2008 +0600
 <at>  <at>  -11,7 +11,7  <at>  <at>  DEFS =  <at> DEFS <at>  -D__COMPILING_SCHEME48_ITS
 DEFS =  <at> DEFS <at>  -D__COMPILING_SCHEME48_ITSELF__ -DS48_HOST_ARCHITECTURE=\"$(HOST_ARCHITECTURE)\"
 LIBS =  <at> LIBS <at> 
 CFLAGS =  <at> CFLAGS <at> 
-CPPFLAGS =
+CPPFLAGS =  <at> CPPFLAGS <at> 
 INSTALL =  <at> INSTALL <at> 
 INSTALL_PROGRAM =  <at> INSTALL_PROGRAM <at> 
 INSTALL_DATA =  <at> INSTALL_DATA <at> 

# HG changeset patch
# User Ivan Shmakov <ivan <at> theory.asu.ru>
# Date 1208272910 -25200
(Continue reading)

Ivan Shmakov | 16 Apr 2008 13:33
Picon

c/scheme48.def: shouldn't it belong to the build directory instead?

	Currently, Makefile.in references the file as
	$(srcdir)/c/scheme48.def.  However, there's no such file in the
	source (as of scheme48-1.8.tar.gz; and it's in .hgignore as
	well), so it gets produced by the build system.

	As I see no apparent reason for this file to reside below
	$(srcdir) (instead of the build directory), may I suggest the
	following patch?  (Thanks to
	s;\$(srcdir)/\(c/scheme48\.def\);\1;.)

--- Makefile.in.~2~	2008-04-16 18:09:41.000000000 +0700
+++ Makefile.in	2008-04-16 18:22:25.000000000 +0700
 <at>  <at>  -313,7 +313,7  <at>  <at> 
 		$(EXTERNAL_OBJECTS)
 	# Cygwin
 	if test -x /usr/bin/dlltool; then \
-		dlltool --dllname $(VM).exe --output-lib $(VM).a --def $(srcdir)/c/scheme48.def; \
+		dlltool --dllname $(VM).exe --output-lib $(VM).a --def c/scheme48.def; \
 	fi

 $(LIBSCHEME48): $(OBJS) $(GC_OBJS) $(UNIX_OBJS) $(LIBOBJS) $(EXTERNAL_OBJECTS)
 <at>  <at>  -409,7 +409,7  <at>  <at> 
 	$(INSTALL_DATA) c/scheme48arch.h $(DESTDIR)$(incdir)
 	$(INSTALL_DATA) $(srcdir)/c/scheme48write-barrier.h $(DESTDIR)$(incdir)
 	$(INSTALL_DATA) $(srcdir)/c/scheme48.exp $(DESTDIR)$(incdir)
-	$(INSTALL_DATA) $(srcdir)/c/scheme48.def $(DESTDIR)$(incdir)
+	$(INSTALL_DATA) c/scheme48.def $(DESTDIR)$(incdir)
 	$(INSTALL_DATA) $(srcdir)/c/scheme48-external.exp $(DESTDIR)$(incdir)
 # install Scheme source files
 	for stub in env big sort opt misc link posix cml srfi; do	\
(Continue reading)

Ivan Shmakov | 16 Apr 2008 13:54
Picon

Makefile.in: Introduce new `EXTERNALS' variable

	May I suggest the following patch?

# HG changeset patch
# User Ivan Shmakov <ivan <at> theory.asu.ru>
# Date 1208346332 -25200
# Node ID 293c27a240bca3713111b574e4e0ed326367b0eb
# Parent  5b4c24ac29beb70c456ac65a9f06209c49044c34
Introduce new `EXTERNALS' Make variable.
Makefile.in (EXTERNALS): New variable, as a short cut to
`$(POSIX_EXTERNAL) $(SRFI_27_EXTERNAL)'.
(enough): Use `$(EXTERNALS)'.
(install): Likewise.
(clean): Likewise.
(check): Likewise.

diff -r 5b4c24ac29be -r 293c27a240bc Makefile.in
--- a/Makefile.in	Tue Apr 15 22:26:05 2008 +0700
+++ b/Makefile.in	Wed Apr 16 18:45:32 2008 +0700
 <at>  <at>  -140,6 +140,7  <at>  <at>  LIBSCHEME48 = c/libscheme48.a
 LIBSCHEME48 = c/libscheme48.a
 POSIX_EXTERNAL = c/posix.so
 SRFI_27_EXTERNAL = c/srfi-27.so
+EXTERNALS = $(POSIX_EXTERNAL) $(SRFI_27_EXTERNAL)
 UNIX_OBJS = c/unix/misc.o c/unix/io.o c/unix/fd-io.o c/unix/event.o
 OBJS =	c/scheme48vm-$(BIT_SUFFIX).o \
 	c/extension.o c/free.o c/double_to_string.o c/bignum.o \
 <at>  <at>  -161,7 +162,8  <at>  <at>  CONFIG_FILES = scheme/interfaces.scm sch

 # The following is the first rule and therefore the "make" command's
 # default target.
(Continue reading)

Ivan Shmakov | 16 Apr 2008 15:58
Picon

doc/src: occurences of `..' and `...'

	It's rather strange to see `..' (or `...') in TeX code (except
	for in, e. g., \verb++.)  I think some of those should be
	replaced as follows (though there're more.)

diff -r 293c27a240bc doc/src/command.tex
--- a/doc/src/command.tex	Wed Apr 16 18:45:32 2008 +0700
+++ b/doc/src/command.tex	Wed Apr 16 20:43:51 2008 +0700
 <at>  <at>  -462,7 +462,7  <at>  <at>  The required argument types are as follo
 \item expressions should be s-expressions
 \item commands (as for \code{,config} and \code{,exec} itself)
  should be lists of the form
- \code{(\cvar{command-name} \cvar{argument} \cvar{...})}
+ \code{(\cvar{command-name} \cvar{argument} \ldots)}
  where \cvar{command-name} is a symbol.
 \end{itemize}

diff -r 293c27a240bc doc/src/external.tex
--- a/doc/src/external.tex	Wed Apr 16 18:45:32 2008 +0700
+++ b/doc/src/external.tex	Wed Apr 16 20:44:19 2008 +0700
 <at>  <at>  -3,7 +3,7  <at>  <at> 

 This chapter describes an interface for calling C functions
  from Scheme, calling Scheme functions from C, and allocating
- storage in the Scheme heap..
+ storage in the Scheme heap.
 Scheme~48 manages stub functions in C that
  negotiate between the calling conventions of Scheme and C and the
  memory allocation policies of both worlds.
diff -r 293c27a240bc doc/src/module.tex
--- a/doc/src/module.tex	Wed Apr 16 18:45:32 2008 +0700
(Continue reading)

Ivan Shmakov | 17 Apr 2008 06:28
Picon

a Scheme48 wrapper for Sqlite3

	In case anyone's interested, here's the alpha version of
	Scheme48 wrapper for Sqlite3.

	The usage is roughly as follows:

> ,new-package
263> ,structure foo (export)
foo> ,open external-calls load-dynamic-externals 
					; ...
foo> ,open records record-types define-record-types os-strings byte-vectors 
					; ...
foo> ,load sqlite3.scm
					; ...
foo> (define db
       (call-with-values (lambda () (sqlite3-open-1 "foo.db"))
			 (lambda (r o)
			   (display " => ") (display r) (newline)
			   o)))
 => 0
; no values returned
foo> (define (get-string byte)
       (os-string-≥string (x->os-string byte)))
; no values returned
foo> (sqlite3-exec db "SELECT 1 AS foo, 2 UNION SELECT 3 AS foo, 4;"
		   (lambda (cb-data columns values names)
		     (write `(cb-data => ,cb-data)) (newline)
		     (write `(columns => ,columns)) (newline)
		     (for-each (lambda (n v)
				 (write `(column ,n => ,v)) (newline))
			       (map get-string (vector->list names))
(Continue reading)

Michael Sperber | 17 Apr 2008 08:13
Picon

Re: c/scheme48.def: shouldn't it belong to the build directory instead?


Ivan Shmakov <ivan <at> theory.asu.ru> writes:

> 	Currently, Makefile.in references the file as
> 	$(srcdir)/c/scheme48.def.  However, there's no such file in the
> 	source (as of scheme48-1.8.tar.gz; and it's in .hgignore as
> 	well), so it gets produced by the build system.
>
> 	As I see no apparent reason for this file to reside below
> 	$(srcdir) (instead of the build directory), may I suggest the
> 	following patch?  (Thanks to
> 	s;\$(srcdir)/\(c/scheme48\.def\);\1;.)

While it is being used only on architecture, its contents are
platform-independent and thus can be shared between builds: That's why
it belongs in $(srcdir).  It should probably be shipped in the tarball,
though.

--

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla


Gmane