Heh... it took a google search to figure out where I put it.
https://github.com/tbreloff/CTechCommon.jl/blob/master/src/macros.jl#L113-L155
On Sun, Oct 9, 2016 at 12:19 PM, Ben Lauwens wrote:
> Hi Tom
>
> I am interested. I am building a macro mimicking how iterator
Hi Tom
I am interested. I am building a macro mimicking how iterator blocks are
transformed in a state-machine in C# (as an alternative to Tasks) and this is
one of the (many) thinks I have to solve. Can you point me to the source? Thanks
Ben
Hey all... I just threw together a quick macro to save some typing when
working with the fields of an object. Disclaimer: this should not be used
in library code, or in anything that will stick around longer than a REPL
session. Hopefully it's self explanatory with this example. Is there a
good
I have a pattern that I frequently use, and I'm considering writing a macro
to automate it, but figured I'd check if it exists already.
I frequently want to have the equivalent of an existing type functionally,
but I want to be able to either dispatch on it or include additional fields
for
Possibly.
Do you have a specific example in mind? That will probably get you a less
ambivalent answer. :-)
Cheers,
Kevin
On Monday, May 9, 2016, Ford Ox wrote:
> Is it possible to write macro that will work as python decorator?
Is it possible to write macro that will work as python decorator?
> and I programmed it as
> julia> macro do_ccall(f,args...)
> :(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end
I belive the arguments should be a tuple expression which you can
generate with Expr(:tuple, [Int for i in 1:length(args)]...)
> julia> macroexpand(:(@do_ccall(f,1,2,3)))
>
Hi,
I'm trying to understand macro expansion, and am a bit stuck. I would like,
in distilled form, to have a macro "@do_ccall" which calls its argument
with Int type. Thus I would like
julia> macroexpand(:(@do_ccall(f,1,2,3)))
:(ccall(f,Int,(Int64,Int64,Int64),args...))
and I programmed it as
Thank you, that solved it.
On Wed, Mar 2, 2016 at 10:54 AM, Yichao Yu wrote:
> On Wed, Mar 2, 2016 at 10:51 AM, Cedric St-Jean
> wrote:
> > Hi, I have a situation that looks a bit like this:
> >
> > module A
> > function foo end
> > end
> >
> >
Hi,
I can't explain the behaviour of this:
macro wtf1()
return esc(
:(begin
@show a
@everywhere const b = a
@show b
end))
end
macro wtf2()
return esc(
:(begin
@show c
const d = c
@show d
when you're writing code that uses macros, supporting different versions of
julia seems to be more complex than normal. in particular, things like:
if VERSION > XX
# code with macros here
end
don't work as expected, because macro expansion occurs before runtime
evaluation. so the macros
ah, great. i won't make a new package then. thanks.
On Thursday, 12 November 2015 09:30:21 UTC-3, Yichao Yu wrote:
>
> https://github.com/JuliaLang/julia/issues/7449
> https://github.com/JuliaLang/Compat.jl/pull/131
> https://github.com/JuliaLang/julia/issues/5892
>
> On Thu, Nov 12, 2015
https://github.com/JuliaLang/julia/issues/7449
https://github.com/JuliaLang/Compat.jl/pull/131
https://github.com/JuliaLang/julia/issues/5892
On Thu, Nov 12, 2015 at 7:23 AM, andrew cooke wrote:
>
> when you're writing code that uses macros, supporting different versions of
>
...and I just discovered Requires.jl. Fantastic stuff.
On Thursday, November 12, 2015 at 8:55:23 PM UTC-8, Seth wrote:
>
> This could be useful to me :)
>
> I have a couple of functions that require JuMP but I don't want to add
> JuMP to my REQUIRE file. My usual tactic of checking
This could be useful to me :)
I have a couple of functions that require JuMP but I don't want to add JuMP
to my REQUIRE file. My usual tactic of checking isdefined(:JuMP) won't work
because JuMP uses macros that are evaluated prior to runtime. However, I
was unable to make the following code
On Thu, Oct 15, 2015 at 8:28 AM, wrote:
> - Do these global variables also refer to function calls like time(),
> println() within a macro??
Yes, time and println are just const global bindings to generic function
objects.
I am kind of confused how to think of the
Hi,
can someone explain what macro definition environment and macro call
environment?
- I was reading the following
page:
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#man-metaprogramming
- it says in the Hygiene section :
Local variables are then renamed to be
Hi,
can someone explain what macro definition environment and macro call
environment?
- I was reading the following page:
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#man-metaprogramming
- it says in the Hygiene section :
"Local variables are then renamed to be
I'm working (in 3.7) on a function that takes two functions f and g as
inputs, merges all non-conflicting methods of f and g into one function h,
and returns h. I'm trying to use macros to generate the signatures of each
method for h:
macro argsgen(typle, n::Int64)
y = eval(:($typle))
The reduced case is:
h((x1::Int64,x2::Int64)...) = x1+1
Which doesn't work, because the ... conflicts with the vararg syntax (the
error message is admittedly not very good).
I would suggest to generate the entire function from your macro, in which
case you can just splice the tuple in and
This is my first time writing macros in Julia. I've read related docs but
could not find an example which works with the arbitrary number of arguments.
So in my example below the args... works correctly with string literals but for
the passed variables it returns their names and not the values.
I know there are type aliases and function assignment.
I find that a macro call is like Expr(:macrocall, symbol(@time),.)
And we can embed a macro inside a macro, but it looks really uncomfortable
to me.
Thanks.
I’m doing some metaprogramming for Interpolations.jl, and I’m getting stuck
at an error that I think is due to scoping issues in my nested quotes, and
I’ve stared at this for so long now I’m not getting anywhere.
I can do the following
matching(d) = quote
println(Matching: , $d)
end
New Julia user here :)
Following the scipy/julia tutorial by D. Sanders and playing around with
Macros
http://nbviewer.ipython.org/github/dpsanders/scipy_2014_julia/blob/master/Metaprogramming.ipynb
He has in there an example of macros. I was playing around with that and I
ran into a case
You need to call esc on the expressions to provide macro hygiene. Sorry for
the brief reply, but let me know if that helps. Btw, did you mean to
include output from macroexpand above? If so, it doesn't seem to have
gotten included.
On Sun, Sep 14, 2014 at 9:28 PM, Zouhair Mahboubi
In your example, nothing is of type Nothing, which is not a MyType, so the
assignment fails.
Tim, for kw arguments, is it true that new functions are specialized for
each type? I'm thought that it wouldn't, which would cause the variable to
be an actual Union type if declared as such, and
i have no idea what is happening here. please can someone explain why
these give such different results? thanks, andrew
cat Memory.jl
immutable Fast{U:Unsigned}
i::U
end
+{U:Unsigned}(a::Fast{U}, b::Fast{U}) = Fast{U}(a.i $ b.i)
immutable Slow{I:Unsigned}
i::I
end
for (name, op)
27 matches
Mail list logo