Jack Trades | 1 Jan 01:06 2009
Picon

A few questions about modules

1.  import, if and define-syntax  --  Where do they come from?  Can they be redefined?

2.  Can I get a list of all the exported functions of a module?

3.  Can I get a list of all defined (and imported) symbols in a module?  In the global environment?

Thanks
Jack Trades

_______________________________________________
Chicken-users mailing list
Chicken-users <at> nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users
William Ramsay | 1 Jan 15:43 2009
Picon
Picon

Xlib text question

Happy New Year,

Can anyone tell me what's going on when I use the following code:

(define xtextproperty-make
  (lambda (textp)
    (let
      ((tp (make-xtextproperty)))

      (set-xtextproperty-value! tp (location textp))
      (set-xtextproperty-encoding! tp XA_STRING)
      (set-xtextproperty-format! tp 32)
      (set-xtextproperty-nitems! tp 1)

      tp)))

Then in my window creation code:

   (let
      ((textprop  (xtextproperty-make   "hello world")))

    .....

      (xsetwmname vs-display vs-window textprop)

    .......

All this compiles and works with on small flaw - all I get for the title 
is "hell" in my window.

Could the fact that I'm doing this on a 64 bit system have anything to 
do with it?    Or am I doing something wrong?

Also the doc for the xlib egg has an error.     Freeing a structure is 
given as:     (free-<NAME>) -> C-POINTER

I think it should be:    (free-<NAME>   C-POINTER)

Bill
felix winkelmann | 4 Jan 16:57 2009
Picon

Re: A few questions about modules

On Thu, Jan 1, 2009 at 1:06 AM, Jack Trades <jacktradespublic <at> gmail.com> wrote:
> 1.  import, if and define-syntax  --  Where do they come from?  Can they be
> redefined?

They are currently handled specially (i.e. hardcoded). The proper
way to do it would be to introduce internal special forms and define
the forms you mention as syntax. Another thing for my todo-list.

>
> 2.  Can I get a list of all the exported functions of a module?

(##sys#module-exports (##sys#find-module '<name>))

will return 3 values:

1) list of exported names
2) list of exported value bindings (a-list)
3) list of exported syntax bindings (a-list, circular)

Note that this is an internal API, so subject to change. There is no
official module API yet.

>
> 3.  Can I get a list of all defined (and imported) symbols in a module?  In
> the global environment?

There is no public API, but the module-structure returned by ##sys#find-module
is defined in line 1265 of expand.scm, the defined-lists may be of interest,
which you can access with ##sys#slot (or block-ref). The parameter
##sys#currrent-environment holds the currently imported bindings.

I hope this is somewhat useful.

cheers,
felix
felix winkelmann | 4 Jan 16:59 2009
Picon

Re: Xlib text question

On Thu, Jan 1, 2009 at 3:43 PM, William Ramsay <ramsayw1 <at> comcast.net> wrote:
>
> Also the doc for the xlib egg has an error.     Freeing a structure is given
> as:     (free-<NAME>) -> C-POINTER
>
> I think it should be:    (free-<NAME>   C-POINTER)
>

Thanks - will be fixed.

cheers,
felix
felix winkelmann | 4 Jan 17:05 2009
Picon

windows shell problem

Hi!

I'm trying to "fix" the mingw build and have encountered
a problem that leaves me absolutely dumbfounded.

I invoke csi and csc in chicken-install like this:

"c:\home\chicken-trunk\bin\csi" ...<args> ...

(Note the quotes around the pathname)

This works fine in cmd.exe, but fails when using the
system(3) function. The behaviour is absolutely incomprehensible
to me, as passing arguments (with or without quoting) makes
it sometimes work and sometimes not. Omitting the quotes
around the program name seems to work, but I can't say
why. There is also no documentation that I can find, which
describes the quoting rules in the windows shell, or what
system(3) is doing behind the scenes. This is mingw
on a relatively old Win XP installation, using the cmd.exe
shell.

Please help. I'm going mad. The moment when I lose control
and throw the whole windows build out of the window is
coming near...

cheers,
felix
Ivan Raikov | 5 Jan 00:08 2009
Picon

Re: windows shell problem


Hi Felix,

   I think the problem is that \ in strings needs to be escaped,
otherwise the string below will include \h \c and \b escape sequences,
instead of the characters \ h c b. 

   -Ivan

"felix winkelmann" <bunny351 <at> gmail.com> writes:

> Hi!
>
> I'm trying to "fix" the mingw build and have encountered
> a problem that leaves me absolutely dumbfounded.
>
> I invoke csi and csc in chicken-install like this:
>
> "c:\home\chicken-trunk\bin\csi" ...<args> ...
>
> (Note the quotes around the pathname)
>
> This works fine in cmd.exe, but fails when using the
> system(3) function. The behaviour is absolutely incomprehensible
> to me, as passing arguments (with or without quoting) makes
> it sometimes work and sometimes not. Omitting the quotes
> around the program name seems to work, but I can't say
> why. There is also no documentation that I can find, which
> describes the quoting rules in the windows shell, or what
> system(3) is doing behind the scenes. This is mingw
> on a relatively old Win XP installation, using the cmd.exe
> shell.
>
> Please help. I'm going mad. The moment when I lose control
> and throw the whole windows build out of the window is
> coming near...
Thomas Chust | 5 Jan 01:27 2009
Picon

Re: windows shell problem

Ivan Raikov wrote:
> [...]
>    I think the problem is that \ in strings needs to be escaped,
> [...]

Hello,

I don't think so, unless the escaping problem occurs on the Scheme or C
side of things.

As far as I know, the Windows shell only understands two escape
characters: The double quote ("), to group things that contain spaces
together and the caret (^) to escape a single following special character.

You can usually enclose things in more than one pair of double quotes
for multiple levels of quoting, however there is no reliable way that I
know of to include double quotes somewhere in the middle of a quoted
string, since at least by the shell no other escape character is
recognized inside double quotes. The caret on the other hand can only be
used to quote certain other characters, like '<', '>', '(', ')', but, if
I recall correctly, it cannot be used to quote spaces or double quotes.

One also has to keep in mind that, unlike under *NIX, the shell is not
responsible for tokenizing command lines into a list of arguments under
Windows. It passes everything after the program name that it doesn't
process itself to the program as a single string and it does not remove
any meta characters from that string. Since the ANSI C standard
prescribes that the main entry point of a program gets a tokenized array
of command line arguments as a parameter, the C library linked into most
programs splits the command line passed by the shell into separate
arguments somehow. However, programs compiled with different tool chains
or linked against different versions of a Windows C runtime library
occasionally have different ideas about how this tokenization should
work. If you have to deal with several such programs, it may be entirely
impossible to quote the command lines correctly.

At least the fact that the shell does not split the command lines but
the application programs do implies that it is impossible to devise a
generally safe and meaningful quoting scheme for Windows shell commands.

cu,
Thomas
Lars Nilsson | 5 Jan 01:37 2009
Picon

Re: windows shell problem

On Sun, Jan 4, 2009 at 7:27 PM, Thomas Chust <chust <at> web.de> wrote:
> Ivan Raikov wrote:
>> [...]
>>    I think the problem is that \ in strings needs to be escaped,
>> [...]
>
> Hello,
>
> I don't think so, unless the escaping problem occurs on the Scheme or C
> side of things.
>
> As far as I know, the Windows shell only understands two escape
> characters: The double quote ("), to group things that contain spaces
> together and the caret (^) to escape a single following special character.

The important part is, I think, that system() is used according to
Felix's first email, presumably in a piece of C code, which means \ in
a string constant should be \\ to be taken literally, instead of
escaping the character following it. The shell / cmd invokation was
supposedly working without a problem.

Lars Nilsson
felix winkelmann | 5 Jan 09:14 2009
Picon

Re: windows shell problem

On Mon, Jan 5, 2009 at 1:37 AM, Lars Nilsson <chamaeleon <at> gmail.com> wrote:
> On Sun, Jan 4, 2009 at 7:27 PM, Thomas Chust <chust <at> web.de> wrote:
>> Ivan Raikov wrote:
>>> [...]
>>>    I think the problem is that \ in strings needs to be escaped,
>>> [...]
>>
>> Hello,
>>
>> I don't think so, unless the escaping problem occurs on the Scheme or C
>> side of things.
>>
>> As far as I know, the Windows shell only understands two escape
>> characters: The double quote ("), to group things that contain spaces
>> together and the caret (^) to escape a single following special character.
>
> The important part is, I think, that system() is used according to
> Felix's first email, presumably in a piece of C code, which means \ in
> a string constant should be \\ to be taken literally, instead of
> escaping the character following it. The shell / cmd invokation was
> supposedly working without a problem.
>

The handling of backslashes as escaping characters is not the problem,
it seems. If I pass this string (verbatim, just like it is printed here) to
system(3):

"c:\home\chicken-trunk\bin\csi" -bnq -e "(require-library setup-api)"
-e "(import setup-api)" "c:\...some...path...\defstruct.setup"

I get an error message that tells me that the program

"c:\home\chicken-trunk\bin\csi" -bnq -e ""

(sic) can not be found.

To reproduce the problem, one can do the following:

- checkout the current svn trunk
- run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1
bootstrap"
  (prefix must contain drive letter and use forward slashes)
- run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1"
- run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1 install"
- run "bin\chicken-install defstruct"

cheers,
felix
felix winkelmann | 5 Jan 09:16 2009
Picon

Re: windows shell problem

On Mon, Jan 5, 2009 at 9:14 AM, felix winkelmann <bunny351 <at> gmail.com> wrote:
>
> - checkout the current svn trunk
> - run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1
> bootstrap"
>  (prefix must contain drive letter and use forward slashes)
> - run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1"
> - run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1 install"
> - run "bin\chicken-install defstruct"
>

Sigh, of course I mean:

- run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1
CHICKEN=chicken-boot"
 - run "make PLATFORM=mingw PREFIX=c:/home/chicken-trunk DEBUGBUILD=1
CHICKEN=chicken-boot install"

cheers,
felix

Gmane