Skip to content

Commit 8199e6e

Browse files
committed
Show experimental warning when namespace is enabled
1 parent 8ecc04d commit 8199e6e

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

common.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11041,6 +11041,7 @@ namespace.$(OBJEXT): $(top_srcdir)/internal/array.h
1104111041
namespace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
1104211042
namespace.$(OBJEXT): $(top_srcdir)/internal/class.h
1104311043
namespace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
11044+
namespace.$(OBJEXT): $(top_srcdir)/internal/error.h
1104411045
namespace.$(OBJEXT): $(top_srcdir)/internal/eval.h
1104511046
namespace.$(OBJEXT): $(top_srcdir)/internal/file.h
1104611047
namespace.$(OBJEXT): $(top_srcdir)/internal/gc.h
@@ -11053,6 +11054,7 @@ namespace.$(OBJEXT): $(top_srcdir)/internal/serial.h
1105311054
namespace.$(OBJEXT): $(top_srcdir)/internal/set_table.h
1105411055
namespace.$(OBJEXT): $(top_srcdir)/internal/st.h
1105511056
namespace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
11057+
namespace.$(OBJEXT): $(top_srcdir)/internal/string.h
1105611058
namespace.$(OBJEXT): $(top_srcdir)/internal/variable.h
1105711059
namespace.$(OBJEXT): $(top_srcdir)/internal/vm.h
1105811060
namespace.$(OBJEXT): $(top_srcdir)/internal/warnings.h

doc/namespace.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Namespace - Ruby's in-process separation of Classes and Modules
2+
3+
Namespace is designed to provide separated spaces in a Ruby process, to isolate applications and libraries.
4+
5+
## Known issues
6+
7+
* Experimental warning is shown when ruby starts with `RUBY_NAMESPACE=1` (specify `-W:no-experimental` command line option to hide it)
8+
9+
## TODOs
10+
11+
## How to use
12+
13+
## Summary
14+
15+
## Specs
16+

internal/namespace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#include "ruby/ruby.h" /* for VALUE */
55

66
/**
7-
* @author Satoshi Tagomori <[email protected]>
7+
* @author Ruby developers <[email protected]>
88
* @copyright This file is a part of the programming language Ruby.
99
* Permission is hereby granted, to either redistribute and/or
1010
* modify this file, provided that the conditions mentioned in the
1111
* file COPYING are met. Consult the file for details.
12-
* @brief Internal header for Fiber.
12+
* @brief Internal header for Namespace.
1313
*/
1414
struct rb_namespace_struct {
1515
/*

namespace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "internal.h"
44
#include "internal/class.h"
55
#include "internal/eval.h"
6+
#include "internal/error.h"
67
#include "internal/file.h"
78
#include "internal/gc.h"
89
#include "internal/hash.h"
@@ -960,6 +961,8 @@ rb_namespace_require_relative(VALUE namespace, VALUE fname)
960961
return rb_ensure(rb_require_relative_entrypoint, fname, namespace_both_pop, (VALUE)&arg);
961962
}
962963

964+
static int namespace_experimental_warned = 0;
965+
963966
void
964967
rb_initialize_main_namespace(void)
965968
{
@@ -968,6 +971,13 @@ rb_initialize_main_namespace(void)
968971
rb_thread_t *th = GET_THREAD();
969972
VALUE main_ns;
970973

974+
if (!namespace_experimental_warned) {
975+
rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL,
976+
"Namespace is experimental, and the behavior may change in the future!\n"
977+
"See doc/namespace.md for know issues, etc.");
978+
namespace_experimental_warned = 1;
979+
}
980+
971981
main_ns = rb_class_new_instance_pass_kw(0, NULL, rb_cNamespace);
972982
ns = rb_get_namespace_t(main_ns);
973983
ns->ns_object = main_ns;

0 commit comments

Comments
 (0)