From 22e953a5064b9aec8286e2d7a7c48fb1c3720ada Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Thu, 16 Jan 2025 20:20:34 +0000 Subject: [PATCH] move internals to a new Internals module --- src/Chevy.jl | 16 ++++++++++++++++ test/unit.jl | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Chevy.jl b/src/Chevy.jl index c36f5af..0722532 100644 --- a/src/Chevy.jl +++ b/src/Chevy.jl @@ -6,6 +6,16 @@ if VERSION ≥ v"1.11" eval(Expr(:public, :enable_repl)) end +function enable_repl end + +function chevy end + +macro chevy end + +module Internals + +import ..Chevy: enable_repl, chevy, @chevy + const tmp_index = Ref(0) """ @@ -97,6 +107,10 @@ Also replaces `<<` in the other direction. - `f(y, z) << x` becomes `f(x, y, z)` - `f(y, __, z) << x` becomes `f(y, x, z)` (note the double underscore) - `x >> f(y) << z` becomes `f(z, x, y)` + +Also `>>>` can be used to keep the previous value. + +- `x >>> f() >> g()` becomes `tmp = x; f(tmp); g(tmp)` """ macro chevy(ex) return esc(chevy(ex)) @@ -216,4 +230,6 @@ function truncate(ex) end end +end + end # module Chevy diff --git a/test/unit.jl b/test/unit.jl index e5a44fd..2935d62 100644 --- a/test/unit.jl +++ b/test/unit.jl @@ -107,14 +107,14 @@ end b end)), ] - @assert Chevy.tmp_index[] == 0 - Chevy.tmp_index[] = 1 + @assert Chevy.Internals.tmp_index[] == 0 + Chevy.Internals.tmp_index[] = 1 try @test chevy(case.input) == case.output finally - Chevy.tmp_index[] = 0 + Chevy.Internals.tmp_index[] = 0 end - @assert Chevy.tmp_index[] == 0 + @assert Chevy.Internals.tmp_index[] == 0 end # syntax errors