Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Link to binaries of Stalin

4 views
Skip to first unread message

phi5...@yahoo.ca

unread,
Mar 8, 2008, 3:38:37 PM3/8/08
to
I am completely unable to build things from binaries. A couple of days
ago, I found a binary distribution for a Scheme implementation whose
name is Stalin. I installed it, tested it, and found out that it is
fast enough for my needs. In Linspire (a distribution of Linux),
installation can be done through the Synaptic Package Manager, and is
quite simple. I would like to have a Windows distribution that is
equaly simple. A cygwin, or a mingw version will do. Finally,
whenever I use something like

(write (integer->string 456))

on Linux, I get a segmentation error. Is this a bug in the Stalin
binary distribution for Linux? BTW, I do not mind about using another
distribution of Scheme for Windows, provided that it is as fast, or
faster than Stalin.

Jeffrey Mark Siskind

unread,
Mar 8, 2008, 8:17:11 PM3/8/08
to
On Mar 8, 3:38 pm, phi50...@yahoo.ca wrote:
> Finally,
> whenever I use something like
>
> (write (integer->string 456))
>
> on Linux, I get a segmentation error. Is this a bug in the Stalin
> binary distribution for Linux?

No this is not a bug.

integer->string is not a standard Scheme procedure. It is specific to
Stalin.
It converts an integer denoting a machine address to a string. It is
the
equivalent to a cast from int to (char *) in C. In the above, most
likely,
you do not have a string at memory address 456.

integer->string, and the related procedures, are intended to be used
with the
foreign procedure interface.

This is all documented in the README that comes with Stalin.

phi5...@yahoo.ca

unread,
Mar 9, 2008, 12:58:40 AM3/9/08
to


Thanx for the prompt answer. In fact, I like very much this Stalin
Scheme, because it is fast, and easy to use, and I would like to learn
more about it. Perhaps you have previous experience with Stalin, and
can give me another piece of information: How can I transform a number
to string in order to do things like draw it on an X window? A short
example would be most helpful. Another question, how do I use foreign
procedures? I know that stalin has a FOREIGN-LANGUAGE interface, but I
do not know how to link a C program to a scheme program. I also do not
know how to include C headers. I tried to mimic what I do in, say,
bigloo, but it did not work. I wrote:

(write ((FOREING-PROCEDURE (CHAR*) INT "atoi") "34") )

Then I get the error: Conflicting types for atoi. Previous declaration
of atoi was here -- stdlib.h

I apologize for asking questions about things that you may think
obvious. I justify myself by saying that people who are not experts in
Computer Science must use computers smile :-)

phi5...@yahoo.ca

unread,
Mar 9, 2008, 3:05:09 AM3/9/08
to

Hi, Jeffrey.

I finally discovered how to call C from Stalin. By using C, I was able
to transform any number to string. Here is what I did:

I wrote a small C program:

#include <stdio.h>

char *xeco(char *res, int x) {
sprintf(res, "%d", x);
return(res);
}

Then, I compiled the small C program:

gcc -c toint.c

Finally, I linked it to Stalin:

(define (xe s)
((FOREIGN-PROCEDURE (CHAR* INT) CHAR* "xeco") "xxxxxxx" s))

I would like to add a few comments. I started my studies of Computer
Science not long ago. I compared Stalin to other Schemes, and found it
very friendly, in the following sense: (1) Stalin does not have a
complex interface to learn, like PLT; type the program in your
favorite text editor, and compile it; (2) Stalin provides more useful
information about bugs at compile time, while other Schemes provide
the same information when the program is already in the hard disk of
the teaching assistant; (3) Stalin generates an easy to use stand
alone exec file; there is no difficulty in preparing a distribution
archive, and handle it to the teaching assistant; all you need to do
is to ship the exec file to the teaching assistant, and it is done;
other Schemes require gigantic distribution files. Finally, I would
like to point out that many teaching assistants want small and fast
programs, with performance close to that provided by C; Stalin satisfy
this requisite.

Abdulaziz Ghuloum

unread,
Mar 9, 2008, 5:26:05 AM3/9/08
to
phi5...@yahoo.ca wrote:

> char *xeco(char *res, int x) {
> sprintf(res, "%d", x);
> return(res);
> }
>

> (define (xe s)
> ((FOREIGN-PROCEDURE (CHAR* INT) CHAR* "xeco") "xxxxxxx" s))

Sorry for being ignorant of how Stalin works, but a few questions:

* Is this supposed to work for all integers? (say 10000000)

* Is it supposed to work if you call it more than once on two
different numbers? (say what's the value of (list (xe 1) (xe 2)) ?)

* How does it work exactly?

Aziz,,,

Aaron Hsu

unread,
Mar 9, 2008, 5:35:13 AM3/9/08
to
phi5...@yahoo.ca writes:

> I compared Stalin to other Schemes, and found it very friendly

Not to disagree with you at all, I think this is the first time I have
ever heard anyone say that! Haha, that's rather interesting. But, I'm
glad you find it so.

For friendliness of debugging environments, I still haven't found any
more enjoyable than MIT Scheme and Chez Scheme. Although, they stand to
be improved, for sure.

--
Aaron Hsu <arc...@sacrideo.us> | Jabber: arc...@jabber.org
``Government is the great fiction through which everybody endeavors to
live at the expense of everybody else.'' - Frederic Bastiat

phi5...@yahoo.ca

unread,
Mar 9, 2008, 12:54:19 PM3/9/08
to
On 9 mar, 06:35, Aaron Hsu <arcf...@sacrideo.us> wrote:

> phi50...@yahoo.ca writes:
> > I compared Stalin to other Schemes, and found it very friendly
>
> Not to disagree with you at all, I think this is the first time I have
> ever heard anyone say that! Haha, that's rather interesting. But, I'm
> glad you find it so.
>
> For friendliness of debugging environments, I still haven't found any
> more enjoyable than MIT Scheme and Chez Scheme. Although, they stand to
> be improved, for sure.
>
> --
> Aaron Hsu <arcf...@sacrideo.us> | Jabber: arcf...@jabber.org

> ``Government is the great fiction through which everybody endeavors to
> live at the expense of everybody else.'' - Frederic Bastiat

Hi, Aaron.
I do not know MIT Scheme. I will try it. I know PLT, Chez Scheme (free
version), Bigloo, Gambit, and Chicken. What annoys me in all these
Schemes that I know is that they do not catch my errors while I am
programming/compiling. Well Bigloo does, but only if I add
declarations to the code, which is not very elegant/friendly, IMHO.
Chicken has a Soft Type System; it works, of course, but one needs to
write the program, and run the typing tool on the program, etc. etc.
It is not very friendly either. PLT tries to be friendly; nice try
smile :-) You enter a very good looking and very slow IDE, that takes
a long time to start up; the first thing that the IDE tries to
discover is your mother tongue; I believe that it looks browse your
computer for it, I do not know. In my case, I got the interface
communicating in Galician, French (probably because I used to live
close to the Canadian border); just now, it insists in producing error
messages using the Hebrew alphabet.

As for Stalin, it catches almost all my errors at compile time. I type
my source program using my favorite text editor. There is one
interesting point. It does not catch all typing errors; there are a
few errors that receives a warning. On the other hand, the error that
I pointed out does not receive even a warning. Since integer->string
is used in most Schemes to mean conversion of integers to their string
representations, I think that it would be a good idea that people who
developed Stalin use other name for the function that creates a
pointer.

The weakest point of Stalin is documentation. It seems that the source
distribution has a README. However, the binary distribution that was
installed automatically in my Linux does not have even that. I am
using Mark Watson's Programming in Scheme to learn how to program with
Stalin. Happily enough pratically all Watson's examples run without
change in Stalin.

I am writing a sort of tutorial for Stalin. In fact, I am translating
the notes that I wrote for Bigloo. I started two days ago, after
failing to find a tutorial in the Internet. I intend to use it to do
my homework for the Functional Programming course, and for the
Artificial Intelligence course. If anybody is attending AI classes,
and want to help me, it would be great; we could exchange assignments,
and help each other with difficult exercises. I want to point out that
Stalin is great for doing things like Neural Network, pattern
recognition, Genetic Algorithms, search, pattern recognition, etc. One
could use it for Numerical Analysis too.

phi5...@yahoo.ca

unread,
Mar 9, 2008, 1:12:08 PM3/9/08
to
On 9 mar, 06:26, Abdulaziz Ghuloum <aghul...@cee.ess.indiana.edu>
wrote:

Hi, Abdulaziz.
Yes, it works for all numbers. At least for numbers that fits the C
types. In fact, it works exactly like INTEGER->STRING in Bigloo. If
you want, I can send you a better implementation of xe. The value of
(list (xe 1) (xe 2)) is ("1" "2"), as one might expect. As far as I am
concerned, Stalin works exactly like other Schemes. It seems to be a
large subset of the Standard Scheme. It does not have bigint though.
However, since it is very easy to link Stalin programs with libraries
written in C (like the Gnu MP Bignum library), it is very easy to add
bignums to Stalin, even for a person who does not know much C, like
myself. If you want to collaborate in my project to document Stalin,
you are welcome. I also intend to exchange ideas for assignments in
Artificial Intelligence, Numerical Analysis, and Functional
Programming. By the way, it is not ease to install Stalin on Windows.
Therefore, I want to solve this problem too: create binaries for
Windows. Finally, I want to write a better GUI for Stalin. You are
most welcome, if you volunteer to help.

I discover Stalin three days ago. Therefore, I do not know much about
it. In my tests, however, it is much better than all other Schemes. If
is much faster, and the compiled programs seem to be much more
reliable. I never get a run time error in Stalin; well, except for
that integer->string error; it is true that I am not using Stalin for
a long time, but even after ten minutes of using PLT, I got 4 runtime
errors.

Jeffrey Mark Siskind

unread,
Mar 9, 2008, 1:18:04 PM3/9/08
to
How can I transform a number to string in order to do things like
draw it
on an X window?

The standard Scheme procedure number->string or the nonstandard
extension
format in Scheme-to-C-compatibility. which you get by doing:

(include "Scheme-to-C-compatibility")

and compiling with the -s, -x, or -q options.

Another question, how do I use foreign procedures? I know that
stalin has a
FOREIGN-LANGUAGE interface, but I do not know how to link a C
program to a
scheme program. I also do not know how to include C headers. I
tried to
mimic what I do in, say, bigloo, but it did not work. I wrote:

(write ((FOREING-PROCEDURE (CHAR*) INT "atoi") "34") )

Then I get the error: Conflicting types for atoi. Previous
declaration of
atoi was here -- stdlib.h

You need to do:

(foreign-procedure (char*) int "atoi" "stdlib")

That tells it to include <stdlib.h> which it will do only once.

> char *xeco(char *res, int x) {
> sprintf(res, "%d", x);
> return(res);
> }

> (define (xe s)
> ((FOREIGN-PROCEDURE (CHAR* INT) CHAR* "xeco") "xxxxxxx" s))

[...] but a few questions:

* Is this supposed to work for all integers? (say 10000000)

* Is it supposed to work if you call it more than once on two
different numbers? (say what's the value of (list (xe 1) (xe 2)) ?)

This should work (on 32-bit machines; for 64-bit machines, change 11
to 20) if
you change the above to:

#include <stdio.h>

char *xeco(char *res, int x) {
sprintf(res, "%d", x);

return res;
}

(define (xe s)
((foreign-procedure (char* int) char* "xeco") (make-string 11) s))

qobi@ingqondo>cat xeco.c
#include <stdio.h>

char *xeco(char *res, int x) {
sprintf(res, "%d", x);

return res;
}
qobi@ingqondo>cat xe.sc
(define (xe s)
((foreign-procedure (char* int) char* "xeco") (make-string 11) s))

(write (xe 10000000))
(newline)
(write (list (xe 1) (xe 2)))
(newline)
qobi@ingqondo>stalin -dc -dH -On -copt xeco.c xe;./xe
In LOOP[1390]
Argument to STRUCTURE-REF might not be a structure of the correct type
In LOOP[1390]
Argument to STRUCTURE-REF might not be a structure of the correct type
In [inside LOOP 1395]
Argument to STRUCTURE-REF might not be a structure of the correct type
In [inside LOOP 1395]
Argument to STRUCTURE-REF might not be a structure of the correct type
In [inside LOOP 1394]
Argument to STRUCTURE-REF might not be a structure of the correct type
In [inside LOOP 1393]
Argument to STRUCTURE-REF might not be a structure of the correct type
In [inside LOOP 1391]
Argument to STRUCTURE-REF might not be a structure of the correct type
In LOOP[1379]
First argument to STRING-REF might not be a string
In LOOP[1379]
First argument to STRING-REF might not be a string
In LOOP[1379]
First argument to STRING-REF might not be a string
"10000000"
("1" "2")
qobi@ingqondo>

Jeffrey Mark Siskind

unread,
Mar 9, 2008, 1:28:56 PM3/9/08
to
By the way, it is not ease to install Stalin on Windows.
> Therefore, I want to solve this problem too: create binaries for
> Windows.

I know of at least two successful ports of Stalin to Windows.
I believe that Martin Rodgers <m...@wildcard.demon.co.uk> has compiled
Stalin
with cygwin and Ben Goetter <goe...@angrygraycat.com> has compiled
Stalin
with Microsoft C.

And I believe that Felix Winkelmann <bunn...@gmail.com> has ported
Stalin to run under Chicken. If there is a port of Chicken to Windows
then
that might also lead (with small modifications to the Stalin code
generator)
to another port of Stalin to Windows.

Aaron Hsu

unread,
Mar 9, 2008, 5:43:48 PM3/9/08
to
phi5...@yahoo.ca writes:

> On 9 mar, 06:35, Aaron Hsu <arcf...@sacrideo.us> wrote:
>> phi50...@yahoo.ca writes:
>> > I compared Stalin to other Schemes, and found it very friendly
>>

>> For friendliness of debugging environments, I still haven't found any
>> more enjoyable than MIT Scheme and Chez Scheme. Although, they stand to
>> be improved, for sure.
>

> I do not know MIT Scheme. I will try it. I know PLT, Chez Scheme (free
> version), Bigloo, Gambit, and Chicken. What annoys me in all these
> Schemes that I know is that they do not catch my errors while I am
> programming/compiling.

[...]

> As for Stalin, it catches almost all my errors at compile time.

Aaah! I see what you want. :-) Yes, most of the Schemes with which I am
familiar (probably all of them) do not do the kind of analysis that
Stalin does to infer the types from the code. That means that, as you
have noted, you won't get a type error until you run the code. I
actually kind of like this behavior, but probably just because I am used
to it. I like to actually run my code to test it, and when I hit an
error, I then run my debugger to trace the execution and discover my
problem pretty quickly. It's interesting that you like the type errors
to be found at compile time though. I guess that would make Stalin
rather interesting.

--
Aaron Hsu <arc...@sacrideo.us> | Jabber: arc...@jabber.org

Jens Axel Soegaard

unread,
Mar 9, 2008, 6:48:49 PM3/9/08
to
phi5...@yahoo.ca wrote:

> I discover Stalin three days ago. Therefore, I do not know much about
> it. In my tests, however, it is much better than all other Schemes. If
> is much faster, and the compiled programs seem to be much more
> reliable. I never get a run time error in Stalin; well, except for
> that integer->string error; it is true that I am not using Stalin for
> a long time, but even after ten minutes of using PLT, I got 4 runtime
> errors.

You could try TypedScheme or - dare I say it - SML.
I tend to think of SML as Scheme with types, so I think
you'll like it.

--
Jens Axel Søgaard

phi5...@yahoo.ca

unread,
Mar 9, 2008, 9:36:10 PM3/9/08
to
On 9 mar, 19:48, Jens Axel Soegaard <inva...@soegaard.net> wrote:

Great. Where can I get TypedScheme? Never heard of it. I heard about a
Scheme called Infer, but all links pointing to its page are broken.

phi5...@yahoo.ca

unread,
Mar 10, 2008, 1:41:41 AM3/10/08
to
My colleagues and I have created a project to solve list of exercises,
homework, and assignment using Stalin. The first thing we need in
order to succeed in this endeavor is a GUI for Stalin, and possibly an
IDE. It is true that Stalin already has a GUI, based on X11 lib.
However, its GUI is not portable, which renders it useless for
assignments, and exercise lists, since the teaching assistant may not
be able to run a X GUI. Therefore, we are writing a GUI based on the
JVM. We created a project on code.google.com, but there is nothing
there yet, since I do not know how to upload. Tomorrow, Junia Magellan
will post the library on

http://code.google.com/p/stalingui/

For the time being, I have posted a prototype on my personal page. If
you guys want to take a look, and make a few comments, here is the
address:

http://www.discenda.org/Stalin/

To test my programs, you must install Stalin, of course. If you are
using Ubuntu, or Linspire, all you have to do is to find the package
Stalin in the Synaptic Package Manager, select it, and press Apply.
Then download and unpack my library. There are two examples. Here is
how to compile them:

stalin -On -copt -ljapi button.sc

stalin -On -copt -ljapi field.sc

The project aims at a complete GUI, working on both Windows, and
Linux. Since the group alread have the GUI for another functional
language (Clean), we believe to finish this part of the work in five
days (it will be ready by the end of the week). Jorlano is working in
the 3D library. I believe that the 3D library will be available in ten
days, and we will have simple games in about one month. Junia is
working on a better documentation for the library and for Stalin
itself. She will finish it in about ten days, but we will post a
tutorial in three of four days for comments, and improving.

By the way, in the appetizer I am sending you, I have not included the
sources for the library. However, you will find the sources in
http://code.google.com/p/stalingui/, both for the GUI and for the 3D
library. The sources are written in Scheme; it is based on Scheme, and
generates C, that is compiled by gcc. The original idea was gotten
from a paper by M Joost and U. Backhaus. The paper is written in
German, and we do not read German (I took Chinese and Latin in
highschool :-). Title:

JAPI Eine Sprachen und Plattformunabhaengige Bibliothek fuer
graphische Benutzeroberflaechen

However, we could understand enough of it to build the library. We
also have another library based on GTK, and on http://www.gtk-server.org/docs.html;
however, this second library uses a dynamic library, and one must
install it on his/her machine. Although the JAPI library is based on
the JVM, one does not need to run Java explicitly to get it installed;
Joost/Backhaus explains the trick in their paper.

BTW, we are happy to accept volunteers. If you want to collaborate
with this project, please send an email to Junia Magellan, and she
will tell you how to update the tutorial, and the libraries (both GTK,
and JVM). You can work on the graphic libraries, on the tutorials, or
helping to solve the assignments/exercises/homework.

0 new messages