Jeff Read | 2 Jul 2012 09:17
Picon

Announcing Glass Table

All,

The thing I've been spare-time hacking on since last week is Glass
Table, a sort of REPL IDE for Gambit. Basically what it does is
remember the definitions you key in at the REPL and saves them to a
sort of "workspace" which you can then save out as a Scheme program
file. You can also load a Scheme file into the workspace, change it by
redefining things, and save it again. Some facility is provided to
save other expressions besides definitions to the workspace but you
have to enable a special option to do so. (See the comments at the top
of glasstable.scm.)

Among other things, this allows you to write and save sophisticated
programs using Gambit for Android, but the idea here is to foster
rapid, iterative development of Scheme code in general with a minimum
of tooling.

I may as well tip my hand: although Glass Table is based on a simple
REPL I crufted up for now, my eventual plan is to hook it into the
Gambit REPL so that it may take advantage of all the powerful goodness
that's provided in Gambit itself for typing in, testing, and debugging
Scheme programs. Hence my REPL-hooking questions earlier.

The repo is available at: https://github.com/bitwize/glasstable/

A tarball is also up at the Dumping Ground.

Happy Scheming,

--Jeff
(Continue reading)

Sven Hartrumpf | 3 Jul 2012 09:39
Picon

Re: How to use define-syntax and cond-expand in one program?

Hello Marc.

Fri, 29 Jun 2012 13:05:01 -0400, feeley wrote:

> The cond-expand macro is defined both in the Gambit runtime and in the
> syntax-case expander.  The native Gambit version accesses the cond-expand
> feature list, but the syntax-case version does not (because it is
> implemented with syntax-rules, which can't execute code which accesses the
> cond-expand feature list).
> 
> The solution would be to rewrite the syntax-case version of cond-expand
> using the syntax-case form.  If you are interested in doing this, the code
> is in lib/psyntax73.ss .

I tried, see attached patch.

> You'll also need a syntax-case version of
> define-cond-expand-feature to avoid phasing problems.

I am unsure how to fix this. Sorry.

Sven
Attachment (psyntax73.ss.patch): text/x-patch, 2632 bytes
_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
(Continue reading)

Andrew Suttles | 3 Jul 2012 16:09
Picon
Gravatar

Creating scheme modules with functions callable from C main program

Folks -


I am writing a simple Windows native app in C using Win32 libraries.  I'd like to to have some of my Windows callback functions call routines that I've written (or will write) in GambitC (because scheme is more fun to write and maintain than C).  I've found material on how to call functions written in C in the scheme interpreter process, but not the other way around.  In other words, when I compile a module of scheme functions into an object file, I don't have a header file to include in my main program written in C.  How do I call those scheme functions?

Thanks again for the help.  I'm fairly new to Scheme and I'm *very new* to GambitC, so please excuse the the naivete of my question.

Andrew

_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Marc Feeley | 3 Jul 2012 16:21
Picon
Gravatar

Re: Creating scheme modules with functions callable from C main program


On 2012-07-03, at 10:09 AM, Andrew Suttles wrote:

> Folks -
> 
> 
> I am writing a simple Windows native app in C using Win32 libraries.  I'd like to to have some of my Windows
callback functions call routines that I've written (or will write) in GambitC (because scheme is more fun
to write and maintain than C).  I've found material on how to call functions written in C in the scheme
interpreter process, but not the other way around.  In other words, when I compile a module of scheme
functions into an object file, I don't have a header file to include in my main program written in C.  How do I
call those scheme functions?

To expose a C function to Scheme you use c-lambda as in

(define puts (c-lambda (char-string) int "puts"))

The string "puts" is the name of the function in C, and the Scheme puts global variable is what is used to call
the function from Scheme code, i.e. (puts "hello!").

To expose a Scheme function to C you use c-define as in

(c-define (write-log s) (char-string) void "write_log" ""
  (display "log: ")
  (display s))

The string "write_log" is the name of the C function to call to execute the write-log Scheme function.  In
general you will also want to have a header file, say log.h which contains the prototype of this function:

/* File: log.h */
void write_log(char *s);

So a module of C code using the write_log function will look like:

#include "log.h"

int main()
{
  write_log("hello\n");
  return 0;
}

Don't forget that you need to initialize the Scheme program and runtime system by firs calling ___setup
(see the example in examples/pthread).

Marc

Marc
Steve Graham | 11 Jul 2012 15:54
Picon
Favicon

Downloading Gambit for Aneroid to Kindle Fire

I tried to do this and the screen at play.google.com says that it is installed, but the device itself shows no such app. Also tried unsuccessfully to load Clojure. Any ideas?

Thanks.

Steve


Sent from Yahoo! Mail on Android

_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Steve Graham | 11 Jul 2012 16:44
Picon
Favicon

Re: Downloading Gambit for Aneroid to Kindle Fire

That should be Android :-)


Sent from Yahoo! Mail on Android


From: Steve Graham <jsgrahamus <at> yahoo.com>;
To: Gambit List <Gambit-list <at> iro.umontreal.ca>;
Subject: [gambit-list] Downloading Gambit for Aneroid to Kindle Fire
Sent: Wed, Jul 11, 2012 1:54:47 PM

I tried to do this and the screen at play.google.com says that it is installed, but the device itself shows no such app. Also tried unsuccessfully to load Clojure. Any ideas?

Thanks.

Steve


Sent from Yahoo! Mail on Android

_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Steve Graham | 11 Jul 2012 20:00
Picon
Favicon

Re: Downloading Gambit for Aneroid to Kindle Fire

Was able to backup app on phone, e-mail to Kindle and install.

Steve


Sent from Yahoo! Mail on Android


From: Steve Graham <jsgrahamus <at> yahoo.com>;
To: Gambit List <Gambit-list <at> iro.umontreal.ca>;
Subject: Re: [gambit-list] Downloading Gambit for Aneroid to Kindle Fire
Sent: Wed, Jul 11, 2012 2:44:26 PM

That should be Android :-)


Sent from Yahoo! Mail on Android


From: Steve Graham <jsgrahamus <at> yahoo.com>;
To: Gambit List <Gambit-list <at> iro.umontreal.ca>;
Subject: [gambit-list] Downloading Gambit for Aneroid to Kindle Fire
Sent: Wed, Jul 11, 2012 1:54:47 PM

I tried to do this and the screen at play.google.com says that it is installed, but the device itself shows no such app. Also tried unsuccessfully to load Clojure. Any ideas?

Thanks.

Steve


Sent from Yahoo! Mail on Android

_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Shihpin Tseng | 14 Jul 2012 03:54
Picon
Gravatar

MeroonV3 cause Xcode random freeze on iPhone real device

I noticed that if run app with MeroonV3 on iPhone real device, Xcode will random freeze, simulator is fine.

It costs me lots of time to find it out.  To someone suffering from this problem also.  :)

ENV: 
gambit 4.6.6 +  cpp project
MeroonV3-2012Jan20.tar.bz2
Xcode 4.3.3
Cyrille Duret | 17 Jul 2012 10:13
Picon

problem with ffi and libxml2

hello,

I have problem to parse xml string with ffi and libxml2.

My code is in the test file libxml-raw.scm :

(c-declare #<<end

#include <stdlib.h>
#include <libxml/xmlreader.h>

xmlTextReaderPtr create_reader(const char* buffer, size_t len) {
  return xmlReaderForMemory(buffer, len, "_.xml", NULL, 0);
}

int first_type_prime(xmlTextReaderPtr reader) {
  int type;
  if( reader != NULL ) {
    int cont = xmlTextReaderRead(reader);
    if( cont ) {
      type = xmlTextReaderNodeType(reader);
      printf("read %d\n", type);
      xmlFreeTextReader(reader);
      return type;
    }
    xmlFreeTextReader(reader);
    return -1;
  }
}

int first_type(const char* s, size_t len) {
  return first_type_prime(create_reader(s, len));
}

end
)

(c-define-type xmlTextReader "xmlTextReader")
(c-define-type xmlTextReaderPtr (pointer xmlTextReader))

(define create-reader
  (c-lambda (nonnull-char-string unsigned-int) xmlTextReaderPtr "create_reader"))
(define first-type-prime
  (c-lambda (xmlTextReaderPtr) int "first_type_prime"))
(define first-type
  (c-lambda (nonnull-char-string unsigned-int) int "first_type"))


Two test functions are defined here :

The first-type function take xml body and create the parser within the c body.
The first-type-prime uses a pointer on xmlTextReader structure stored and the scheme-side.

The first-type-prime function fails and I don't know what's going on :

<at> gsc-gambit            
Gambit v4.6.4

> (compile-file "libxml-raw.scm" 'cc-options: "-Wno-write-strings -U___SINGLE_HOST -I/usr/local/include/libxml2" 'ld-options: "-L/usr/local/lib/ -lxml2")
"/usr/users/cydu/programming/scheme/modules/xml/libxml-raw.o1"
> (load "libxml-raw")                                                          
"/usr/users/cydu/programming/scheme/modules/xml/libxml-raw.o1"            
> (define r (create-reader "<xml>toto</xml>" 15))                                                                  
> r
#<xmlTextReader* #2 0x801781300>
> (first-type-prime r)                                                         
_.xml:1: parser error : Char 0x0 out of allowed range                     
<xml
    ^
_.xml:1: parser error : Couldn't find end of Start Tag xml
<xml
    ^
read 0
0
>

while this call works :

> (first-type "<xml>toto</xml>" 15)                                 
read 1
1

Any idea what's happened ?
thanks a lot
cyrille


_______________________________________________
Gambit-list mailing list
Gambit-list <at> iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Klaus Schilling | 17 Jul 2012 11:55
Picon

Re: problem with ffi and libxml2

From: Cyrille Duret <cduret <at> gmail.com>
Subject: [gambit-list] problem with ffi and libxml2
Date: Tue, 17 Jul 2012 10:13:10 +0200

> hello,
> I have problem to parse xml string with ffi and libxml2.
> 
> My code is in the test file libxml-raw.scm :
> 
> (c-declare #<<end
> 
> #include <stdlib.h>
> #include <libxml/xmlreader.h>
> 
> xmlTextReaderPtr create_reader(const char* buffer, size_t len) {
>   return xmlReaderForMemory(buffer, len, "_.xml", NULL, 0);
> }

What are the major advantages of using libxml2 xmlreader with ffi over
using sxml?

Klaus Schilling

Gmane