From: tantalum <sph@posteo.eu>
To: <guile-user@gnu.org>
Subject: Re: sph.io libraries
Date: Tue, 22 Jul 2014 13:12:28 +0200 [thread overview]
Message-ID: <98916f500743b0b76f68813c3bce390d@posteo.de> (raw)
> Neat. Just to double-check - the environment variables of my current
> process are
> preserved or /tmp/mybin would run with environment consisting only of
> variables which
> I've explicitly put into execute-with-environment?
the new process receives only the specified environment variables. but
it should be no problem to pass it a
modified environment from the current process using guiles "environ"
procedure
(cons "XX2=LOL" (environ))
working example:
guile -c '(import (sph process)) (execute-with-environment (cons
"XX2=LOL" (environ)) "env")'
> the only interface to execve for guile
actually in guile the direct interface to execve is called execle
(https://www.gnu.org/software/guile/manual/html_node/Processes.html#index-execle).
the "process" version does two more things:
- it adds the program name as the first argument, the usual calling
convention. would have to be taken care of manually otherwise
- it may search $PATH
- it moves the "env" argument to the front to preserve the order of
filename and rest-arguments
> Could you illustrate that with some code too? I do not plan to have
> that many records
> so I'm not concerned with the speed that much :)
the getter/setter definitions where included in the last example.
setting fields by symbolic name would look like this:
(define triad (make-record-layout (quote (pid env num))))
(define t (record triad pid "LOL" 5))
(record-set! t triad (quote pid) 5011)
the getter/setter definitions could be shortened with a new single
"define-" form which generates the bindings. i might add that and the
current library makes this quite easy.
for reference, other record implementations already do this, but these
implementations regard records as something more complicated.
https://www.gnu.org/software/guile/manual/html_node/rnrs-records-syntactic.html#rnrs-records-syntactic
https://www.gnu.org/software/guile/manual/html_node/SRFI_002d9-Records.html#SRFI_002d9-Records
if you do not want to deal with record-layouts, getters and setters,
you could use vectors which are like arrays in other languages (which
could be records at the same time)
(define a (vector 3 4 5))
(vector-ref a 0)
or hashtables, which are like associative arrays or objects in other
languages
(import (sph hashtable))
(define a (hashtable "a" 1 "b" 2))
(hashtable-ref a "a")
or association lists, alists, which are lists and similar to
two-dimensional arrays
(import (sph alist))
(define a (alist "a" 1 "b" 2))
(alist-ref a "a")
(https://www.gnu.org/software/guile/manual/html_node/Association-Lists.html#Association-Lists
https://www.gnu.org/software/guile/manual/html_node/SRFI_002d1-Association-Lists.html#SRFI_002d1-Association-Lists)
> I can also have arbitrary number of fields in the record?
yes
> your libraries to be packaged and readily available in my distro
> repositories
what is your distro?
there is a package for arch linux at least
(https://aur.archlinux.org/packages/sph-lib-git)
and there is "guix", which seems to become the package manager for the
gnu system, and might be interesting cross-distro. though as of yet i
have not figured out how to make a package for it.
next reply other threads:[~2014-07-22 11:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 11:12 tantalum [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-07-21 15:48 sph.io libraries tantalum
2014-07-21 16:15 ` Max
2014-07-21 19:03 ` tantalum
2014-07-21 21:59 ` Max
2014-07-08 13:52 Max
2014-07-08 14:50 ` Taylan Ulrich Bayirli/Kammer
2014-07-08 14:53 ` Thompson, David
2014-07-10 11:09 ` Max
2014-07-10 18:56 ` Taylan Ulrich Bayirli/Kammer
2014-07-10 18:59 ` Max
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98916f500743b0b76f68813c3bce390d@posteo.de \
--to=sph@posteo.eu \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).