Skip to content

Commit b1c1f5d

Browse files
Ovidrjbs
authored andcommitted
Move to a branch and address issues raised in #14
1 parent 697c901 commit b1c1f5d

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

rfcs/rfc0018.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
## Abstract
1111

1212
This RFC proposes a `yield_true` feature. When used, the current Perl _file_
13-
containing `use feature 'yield_true'l` will automatically return a true value
14-
after successful compilation, eliminating the neeed for a "1" (or other true
13+
containing `use feature 'yield_true';` will automatically return a true value
14+
after successful compilation, eliminating the need for a "1" (or other true
1515
value) at the end of the file.
1616

1717
## Motivation
@@ -26,13 +26,18 @@ _doesn't_ end with a true value but nonetheless compiles just fine because
2626
_something_ in the code returned a true value and the code compiles as a
2727
side-effect.
2828

29-
3029
## Specification
3130

3231
use feature 'yield_true';
3332

3433
Code using the above does not need to return a magic true value when compiled.
3534

35+
If the module explicitly returns a false value, we should consider if this can
36+
be ignored (I suspect this is usually a bug). However, the module author
37+
_might_ have conditional logic to explicitly return a false value in case
38+
there's a missing dependency (or for some other reason). Discussion might be
39+
useful here.
40+
3641
## Backwards Compatibility
3742

3843
There are no compatibility concerns I'm aware of.
@@ -47,19 +52,50 @@ None. See above.
4752

4853
## Prototype Implementation
4954

50-
None.
55+
There is a prototype implementation at [true](https://metacpan.org/pod/true).
5156

5257
## Future Scope
5358

54-
I believe this is complete.
59+
Due to this being a named feature, this can eventually be the default behavior
60+
when `use v5.XX;` is used.
5561

5662
## Rejected Ideas
5763

58-
None that I'm aware of.
64+
It's been discussed that we should return the package name instead. This
65+
supports:
66+
67+
my $obj = (require Some::Object::Class)->new;
68+
69+
However, per haarg:
70+
71+
> Changing the return value of require seems like a separate issue from what
72+
> this RFC wants to address.
73+
>
74+
> If you wanted require to always return the same value, and for that value to
75+
> come from the file, you need a new location to store these values. This
76+
> would probably mean a new superglobal to go along with %INC. And it would
77+
> usually be useless because most modules return 1. I don't think this is a
78+
> very good idea.
79+
>
80+
> If you wanted require to always return the package name, it's a separate
81+
> issue from this RFC because that means ignoring the return value from the
82+
> file. It also presents a problem because require doesn't actually take
83+
> package names. It takes file path fragments. Foo::Bar is translated to
84+
> "Foo/Bar.pm" at parse time. This would then need to be converted back to a
85+
> package name, or do something else. I don't think this is a good idea
86+
> either.
87+
>
88+
> Instead, it's probably best addressed with a builtin::load or similar
89+
> routine that accepts a package as a string. This has been discussed in the
90+
> past, and solves other problems. Module::Runtime has a use_module function
91+
> that behaves like this, returning the package name.
92+
93+
Thus, we prefer simply returning `true` (or `1`).
5994

6095
## Open Issues
6196

62-
None that I'm aware of.
97+
* Should returning a false value be ignored?
98+
* Should any explicit return be an error?
6399

64100
## Copyright
65101

0 commit comments

Comments
 (0)