diff --git a/libguile/read.c b/libguile/read.c index 51dffbf3a..1d7ca78a0 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -1,4 +1,4 @@ -/* Copyright 1995-1997,1999-2001,2003-2004,2006-2012,2014-2020 +/* Copyright 1995-1997,1999-2001,2003-2004,2006-2012,2014-2021 Free Software Foundation, Inc. This file is part of Guile. @@ -1943,12 +1943,12 @@ scm_read_expression (SCM port, scm_t_read_opts *opts) static void init_read_options (SCM port, scm_t_read_opts *opts); -SCM_DEFINE (scm_read, "read", 0, 1, 0, +SCM_DEFINE (scm_primitive_read, "primitive-read", 0, 1, 0, (SCM port), "Read an s-expression from the input port @var{port}, or from\n" "the current input port if @var{port} is not specified.\n" "Any whitespace before the next token is discarded.") -#define FUNC_NAME s_scm_read +#define FUNC_NAME s_scm_primitive_read { scm_t_read_opts opts; int c; @@ -1968,6 +1968,19 @@ SCM_DEFINE (scm_read, "read", 0, 1, 0, } #undef FUNC_NAME +static SCM scm_read_var; + +SCM +scm_read (SCM port) +#define FUNC_NAME "read" +{ + if (SCM_UNBNDP (port)) + return scm_call_0 (scm_variable_ref (scm_read_var)); + + return scm_call_1 (scm_variable_ref (scm_read_var), port); +} +#undef FUNC_NAME + @@ -2399,4 +2412,7 @@ scm_init_read () scm_init_opts (scm_read_options, scm_read_opts); #include "read.x" + + scm_read_var = scm_c_define + ("read", scm_variable_ref (scm_c_lookup (s_scm_primitive_read))); } diff --git a/libguile/read.h b/libguile/read.h index 94d92db4a..c3d62cd15 100644 --- a/libguile/read.h +++ b/libguile/read.h @@ -1,7 +1,7 @@ #ifndef SCM_READ_H #define SCM_READ_H -/* Copyright 1995-1996,2000,2006,2008-2009,2018 +/* Copyright 1995-1996,2000,2006,2008-2009,2018,2021 Free Software Foundation, Inc. This file is part of Guile. @@ -49,6 +49,8 @@ SCM_API SCM scm_sym_dot; +SCM_INTERNAL SCM scm_primitive_read (SCM port); + SCM_API SCM scm_read_options (SCM setting); SCM_API SCM scm_read (SCM port); SCM_API SCM scm_read_hash_extend (SCM chr, SCM proc);