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)
|
|
|
|
|
|
|
2002-08-04 00:17:18 +00:00
|
|
|
|
/~#include "libguile/ports.h"
|
2001-06-07 21:12:19 +00:00
|
|
|
|
#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
|
|
|
|
{
|
Changes in doc/ref:
* api.txt, data-rep.texi: Renamed the struct scm_cell to
scm_t_cell.
* data-rep.texi: Renamed scm_alloc_cell to scm_cell and
scm_alloc_double_cell to scm_double_cell.
Changes in libguile:
* gc.c (SCM_HEAP_SEG_SIZE, CELL_UP, CELL_DN, NEXT_DATA_CELL,
init_heap_seg, alloc_some_heap), gc.h (struct scm_cell, struct
scm_t_cell, SCM_CELLPTR, SCM_GC_CARD_SIZE,
SCM_GC_IN_CARD_HEADERP), tags.h (SCM_CELLP): Renamed the struct
scm_cell and all its uses to scm_t_cell in accordance to Guile's
naming scheme for types.
* alist.c (scm_acons), convert.i.c (CTYPES2UVECT,
CTYPES2UVECT_OPTIONAL), coop-threads.c (scm_call_with_new_thread,
scm_spawn_thread), debug.c (scm_make_debugobj), environments.c
(scm_make_environment), eval.c (scm_closure), fports.c
(scm_fdes_to_port), gc.c (scm_deprecated_newcell,
scm_deprecated_newcell2), inline.h (scm_alloc_cell, scm_cell),
list.c (SCM_I_CONS), numbers.c (scm_i_mkbig), pairs.c (scm_cons),
ports.c (scm_void_port), procs.c (scm_c_make_subr, scm_makcclo),
smob.c (scm_make_smob), smob.h (SCM_NEWSMOB), strings.c
(scm_take_str, scm_allocate_string), strports.c (scm_mkstrport),
unif.c (scm_make_uve), variable.c (make_variable), vectors.c
(scm_c_make_vector), vports.c (scm_make_soft_port): Renamed
scm_alloc_cell to scm_cell.
* environments.c (core_environments_observe), gc.c
(scm_deprecated_newcell2), goops.c (wrap_init, scm_wrap_object),
inline.h (scm_alloc_double_cell, scm_double_cell), num2float.i.c
(FLOAT2NUM), numbers.c (scm_make_real), procs.c
(scm_make_procedure_with_setter), smob.h (SCM_NEWSMOB2,
SCM_NEWSMOB3), struct.c (scm_make_struct, scm_make_vtable_vtable),
symbols.c (scm_mem2symbol, scm_mem2uninterned_symbol), weaks.c
(allocate_weak_vector): Renamed scm_alloc_double_cell to
scm_double_cell.
2002-03-01 00:19:20 +00:00
|
|
|
|
return scm_cell (SCM_UNPACK (x), SCM_UNPACK (y));
|
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
|
|
|
|
|
* __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
|
|
|
|
{
|
2001-11-25 15:21:07 +00:00
|
|
|
|
return scm_cons (w, scm_cons (x, y));
|
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
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/pairs.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|