2001-06-07 21:12:19 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
|
* any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this software; see the file COPYING. If not, write to
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
|
|
* Boston, MA 02111-1307 USA
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* As a special exception, the Free Software Foundation gives permission
|
|
|
|
|
|
* for additional uses of the text contained in its release of GUILE.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The exception is that, if you link the GUILE library with other files
|
|
|
|
|
|
* to produce an executable, this does not by itself cause the
|
|
|
|
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
|
|
|
|
* Your use of that executable is in no way restricted on account of
|
|
|
|
|
|
* linking the GUILE library code into it.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception does not however invalidate any other reasons why
|
|
|
|
|
|
* the executable file might be covered by the GNU General Public License.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception applies only to the code released by the
|
|
|
|
|
|
* Free Software Foundation under the name GUILE. If you copy
|
|
|
|
|
|
* code from other Free Software Foundation releases into a copy of
|
|
|
|
|
|
* GUILE, as the General Public License permits, the exception does
|
|
|
|
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
|
|
|
|
* anyone as to the status of such modified files, you must delete
|
|
|
|
|
|
* this exception notice from them.
|
|
|
|
|
|
*
|
|
|
|
|
|
* If you write modifications of your own for GUILE, it is your choice
|
|
|
|
|
|
* whether to permit this exception to apply to your modifications.
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* If you do not wish that, delete this exception notice. */
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-05-05 16:19:30 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/validate.h"
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
2000-05-05 16:19:30 +00:00
|
|
|
|
#include "libguile/pairs.h"
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* {Pairs}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2001-06-07 21:12:19 +00:00
|
|
|
|
#if (SCM_DEBUG_PAIR_ACCESSES == 1)
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/ports.h"
|
|
|
|
|
|
#include "libguile/strings.h"
|
|
|
|
|
|
|
|
|
|
|
|
void scm_error_pair_access (SCM non_pair)
|
|
|
|
|
|
{
|
2001-06-08 10:02:33 +00:00
|
|
|
|
static unsigned int running = 0;
|
2001-06-07 21:12:19 +00:00
|
|
|
|
SCM message = scm_makfrom0str ("Non-pair accessed with SCM_C[AD]R: `~S<>\n");
|
2001-06-08 10:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
if (!running)
|
|
|
|
|
|
{
|
|
|
|
|
|
running = 1;
|
|
|
|
|
|
scm_simple_format (scm_current_error_port (),
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
message, scm_list_1 (non_pair));
|
2001-06-08 10:02:33 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
}
|
2001-06-07 21:12:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_cons, "cons", 2, 0, 0,
|
2000-05-05 16:19:30 +00:00
|
|
|
|
(SCM x, SCM y),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return a newly allocated pair whose car is @var{x} and whose\n"
|
|
|
|
|
|
"cdr is @var{y}. The pair is guaranteed to be different (in the\n"
|
|
|
|
|
|
"sense of @code{eq?}) from every previously existing object.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_cons
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-05 16:19:30 +00:00
|
|
|
|
SCM z;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM_NEWCELL (z);
|
2000-05-05 16:19:30 +00:00
|
|
|
|
SCM_SET_CELL_OBJECT_0 (z, x);
|
|
|
|
|
|
SCM_SET_CELL_OBJECT_1 (z, y);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return z;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_cons2 (SCM w, SCM x, SCM y)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-05 16:19:30 +00:00
|
|
|
|
SCM z1;
|
|
|
|
|
|
SCM z2;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_NEWCELL (z1);
|
|
|
|
|
|
SCM_SET_CELL_OBJECT_0 (z1, x);
|
|
|
|
|
|
SCM_SET_CELL_OBJECT_1 (z1, y);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_NEWCELL (z2);
|
|
|
|
|
|
SCM_SET_CELL_OBJECT_0 (z2, w);
|
|
|
|
|
|
SCM_SET_CELL_OBJECT_1 (z2, z1);
|
|
|
|
|
|
|
|
|
|
|
|
return z2;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_pair_p, "pair?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return @code{#t} if @var{x} is a pair; otherwise return\n"
|
|
|
|
|
|
"@code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_pair_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-05 16:19:30 +00:00
|
|
|
|
return SCM_BOOL (SCM_CONSP (x));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-05-05 16:19:30 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_set_car_x, "set-car!", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM pair, SCM value),
|
2000-02-07 04:30:17 +00:00
|
|
|
|
"Stores @var{value} in the car field of @var{pair}. The value returned\n"
|
|
|
|
|
|
"by @code{set-car!} is unspecified.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_car_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-05 16:19:30 +00:00
|
|
|
|
SCM_VALIDATE_CONS (1, pair);
|
1999-01-13 08:28:52 +00:00
|
|
|
|
SCM_SETCAR (pair, value);
|
1999-03-22 01:22:04 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-05-05 16:19:30 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_set_cdr_x, "set-cdr!", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM pair, SCM value),
|
2000-02-07 04:30:17 +00:00
|
|
|
|
"Stores @var{value} in the cdr field of @var{pair}. The value returned\n"
|
|
|
|
|
|
"by @code{set-cdr!} is unspecified.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_cdr_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-05 16:19:30 +00:00
|
|
|
|
SCM_VALIDATE_CONS (1, pair);
|
1999-01-13 08:28:52 +00:00
|
|
|
|
SCM_SETCDR (pair, value);
|
1999-03-22 01:22:04 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-04-25 09:45:16 +00:00
|
|
|
|
static const char * cxrs[] =
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-04-25 09:45:16 +00:00
|
|
|
|
"car",
|
|
|
|
|
|
"cdr",
|
|
|
|
|
|
"caar",
|
|
|
|
|
|
"cadr",
|
|
|
|
|
|
"cdar",
|
|
|
|
|
|
"cddr",
|
|
|
|
|
|
"caaar",
|
|
|
|
|
|
"caadr",
|
|
|
|
|
|
"cadar",
|
|
|
|
|
|
"caddr",
|
|
|
|
|
|
"cdaar",
|
|
|
|
|
|
"cdadr",
|
|
|
|
|
|
"cddar",
|
|
|
|
|
|
"cdddr",
|
|
|
|
|
|
"caaaar",
|
|
|
|
|
|
"caaadr",
|
|
|
|
|
|
"caadar",
|
|
|
|
|
|
"caaddr",
|
|
|
|
|
|
"cadaar",
|
|
|
|
|
|
"cadadr",
|
|
|
|
|
|
"caddar",
|
|
|
|
|
|
"cadddr",
|
|
|
|
|
|
"cdaaar",
|
|
|
|
|
|
"cdaadr",
|
|
|
|
|
|
"cdadar",
|
|
|
|
|
|
"cdaddr",
|
|
|
|
|
|
"cddaar",
|
|
|
|
|
|
"cddadr",
|
|
|
|
|
|
"cdddar",
|
|
|
|
|
|
"cddddr",
|
|
|
|
|
|
0
|
1996-07-25 22:56:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_pairs ()
|
|
|
|
|
|
{
|
2000-04-25 09:45:16 +00:00
|
|
|
|
unsigned int subnr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (subnr = 0; cxrs [subnr]; subnr++)
|
(scm_c_make_gsubr, scm_c_define_gsubr, scm_c_make_gsubr_with_generic,
scm_c_define_gsubr_with_generic): New functions. They replace
scm_make_gsubr and scm_make_gsubr_with_generic. The `make' variants
only create the gsubr object, while the `define' variants also put it
into the current module. Changed all callers. (scm_make_gsubr,
scm_make_gsubr_with_generic): Deprecated.
(scm_c_make_subr, scm_c_define_subr, scm_c_make_subr_with_generic,
scm_c_define_subr_with_generic): New functions. They replace
scm_make_subr, scm_make_subr_opt and scm_make_subr_with_generic. The
`make' variants only create the subr object, while the `define'
variants also put it into the current module. Changed all callers.
(scm_make_subr, scm_make_subr_opt, scm_make_subr_with_generic):
Deprecated.
2001-05-20 00:35:43 +00:00
|
|
|
|
scm_c_define_subr (cxrs [subnr], scm_tc7_cxr, NULL);
|
2000-04-25 09:45:16 +00:00
|
|
|
|
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#ifndef SCM_MAGIC_SNARFER
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/pairs.x"
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|