Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate rvalues consisting only of underscores #24221

Merged
merged 2 commits into from
Oct 20, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
deprecate rvalues consisting only of underscores
stevengj committed Oct 19, 2017
commit a74474de3902a39daa365cdb6d9f3cdc60b97dcf
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -118,6 +118,9 @@ Language changes
* `reduce(+, [...])` and `reduce(*, [...])` no longer widen the iterated over arguments to
system word size. `sum` and `prod` still preserve this behavior. ([#22825])

* Like `_`, variable names consisting only of underscores can be assigned,
but accessing their values is deprecated ([]).

Breaking changes
----------------

4 changes: 2 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
@@ -208,8 +208,8 @@ function parse_input_line(s::String; filename::String="none")
# expr
ex = ccall(:jl_parse_input_line, Any, (Ptr{UInt8}, Csize_t, Ptr{UInt8}, Csize_t),
s, sizeof(s), filename, sizeof(filename))
if ex === :_
# remove with 0.6 deprecation
if ex isa Symbol && all(equalto('_'), string(ex))
# remove with 0.7 deprecation
expand(Main, ex) # to get possible warning about using _ as an rvalue
end
return ex
11 changes: 11 additions & 0 deletions src/flisp/julia_extensions.c
Original file line number Diff line number Diff line change
@@ -210,6 +210,16 @@ value_t fl_julia_strip_op_suffix(fl_context_t *fl_ctx, value_t *args, uint32_t n
return opnew_symbol;
}

/* check whether arg is a symbol that consists solely of underscores. */
value_t fl_julia_underscore_symbolp(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
{
argcount(fl_ctx, "underscore-symbol?", nargs, 1);
if (!issymbol(args[0])) return fl_ctx->F;
char *op = symbol_name(fl_ctx, args[0]);
while (*op == '_') ++op;
return *op ? fl_ctx->F : fl_ctx->T;
}

#include "julia_charmap.h"

utf8proc_int32_t jl_charmap_map(utf8proc_int32_t c, void *ctx)
@@ -298,6 +308,7 @@ static const builtinspec_t julia_flisp_func_info[] = {
{ "identifier-start-char?", fl_julia_identifier_start_char },
{ "op-suffix-char?", fl_julia_op_suffix_char },
{ "strip-op-suffix", fl_julia_strip_op_suffix },
{ "underscore-symbol?", fl_julia_underscore_symbolp },
{ NULL, NULL }
};

4 changes: 2 additions & 2 deletions src/jlfrontend.scm
Original file line number Diff line number Diff line change
@@ -100,8 +100,8 @@
(or (memq (car e) '(toplevel line module import importall using export
error incomplete))
(and (eq? (car e) 'global) (every symbol? (cdr e))))))
(if (eq? e '_)
(syntax-deprecation #f "_ as an rvalue" ""))
(if (underscore-symbol? e)
(syntax-deprecation #f "underscores as an rvalue" ""))
e)
(else
(let ((last *in-expand*))
6 changes: 3 additions & 3 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
@@ -3515,11 +3515,11 @@ f(x) = yt(x)
(let ((e1 (if (and arg-map (symbol? e))
(get arg-map e e)
e)))
(if (and value (or (eq? e '_)
(if (and value (or (underscore-symbol? e)
(and (pair? e) (or (eq? (car e) 'outerref)
(eq? (car e) 'globalref))
(eq? (cadr e) '_))))
(syntax-deprecation #f (string "_ as an rvalue" (linenode-string current-loc))
(underscore-symbol? (cadr e)))))
(syntax-deprecation #f (string "underscores as an rvalue" (linenode-string current-loc))
""))
(if (and (not *warn-all-loop-vars*) (has? deprecated-loop-vars e))
(begin (deprecation-message