Re: [julia-users] Re: Can I use macro to substitute the argument list of a function?

2015-01-08 Thread Chi-wei Wang
by Greg). Jason Merrill於 2015年1月8日星期四 UTC-8上午11時37分33秒寫道: Can you give more context about what high level goal you are trying to achieve? Why do you want to splice arguments in this particular way? On Wednesday, January 7, 2015 8:25:16 PM UTC-8, Chi-wei Wang wrote: Any ways to achieve

[julia-users] Re: Can I use macro to substitute the argument list of a function?

2015-01-07 Thread Chi-wei Wang
Can ... be applied on macro? I tried this but it didn't compile. macro f(a,b,c) return :($a+$b+$c) end const A = (2,3) @f(1, A...) Chi-wei Wang於 2015年1月7日星期三UTC-8下午6時45分14秒寫道: It works! I missed the varargs section in the doc. Thanks! Greg Plowman於 2015年1月7日星期三UTC-8下午5時26分02秒寫道: Would

Re: [julia-users] Re: Can I use macro to substitute the argument list of a function?

2015-01-07 Thread Chi-wei Wang
07 2015 at 10:04:26 PM Chi-wei Wang cwwa...@gmail.com javascript: wrote: Can ... be applied on macro? I tried this but it didn't compile. macro f(a,b,c) return :($a+$b+$c) end const A = (2,3) @f(1, A...) Chi-wei Wang於 2015年1月7日星期三UTC-8下午6時45分14秒寫道: It works! I missed the varargs

[julia-users] Can I use macro to substitute the argument list of a function?

2015-01-07 Thread Chi-wei Wang
Hi, everyone. I am trying to achieve the effect like the following C code: #define A 1,2,3 void f(int x, int y, int z) { } f(A); Yet the macro in Julia always returns a single expression. Is it possible to do this?

[julia-users] Re: Can I use macro to substitute the argument list of a function?

2015-01-07 Thread Chi-wei Wang
, January 8, 2015 11:14:23 AM UTC+11, Chi-wei Wang wrote: Hi, everyone. I am trying to achieve the effect like the following C code: #define A 1,2,3 void f(int x, int y, int z) { } f(A); Yet the macro in Julia always returns a single expression. Is it possible to do this?

Re: [julia-users] How can I achieve C-like ## in Julia

2015-01-06 Thread Chi-wei Wang
May I ask why $ is needed before symbol()? Mike Innes於 2015年1月7日星期三UTC+8上午10時02分27秒寫道: Cool. $(symbol(gen_$x)) might also be a bit more compact, now I think about it. On 7 January 2015 at 02:00, Chi-wei Wang cwwa...@gmail.com javascript: wrote: Exactly what I want! Thanks! Mike Innes於

Re: [julia-users] How can I achieve C-like ## in Julia

2015-01-06 Thread Chi-wei Wang
Exactly what I want! Thanks! Mike Innes於 2015年1月7日星期三UTC+8上午9時34分21秒寫道: Is $(symbol(string(gen_, x))) what you're looking for? On 7 January 2015 at 01:28, Chi-wei Wang cwwa...@gmail.com javascript: wrote: Hi, everyone. I'd like to do something like following C code in Julia. #define

[julia-users] How can I achieve C-like ## in Julia

2015-01-06 Thread Chi-wei Wang
Hi, everyone. I'd like to do something like following C code in Julia. #define gen_func(x) \ void f_##x() { \ } I tried the following Julia code, but I have no idea how to get 'gen_' appended in front of the function name. macro gen_func(x) return esc(quote function $x() # do

[julia-users] Re: InexactError due to negative hexadecimal number

2015-01-05 Thread Chi-wei Wang
integer 0xedcba988 which is greater than typemax(Int32). So the value is too large to represent as a signed Int32. On Monday, January 5, 2015 5:43:20 PM UTC-8, Chi-wei Wang wrote: julia version 0.4.0-dev+2496 Program: println(-0x12345678) println(0-0x12345678) println(int32(0-0x12345678

[julia-users] InexactError due to negative hexadecimal number

2015-01-05 Thread Chi-wei Wang
julia version 0.4.0-dev+2496 Program: println(-0x12345678) println(0-0x12345678) println(int32(0-0x12345678)) println(int32(-0x12345678)) Output: 3989547400 -305419896 -305419896 ERROR: InexactError() in include at ./boot.jl:248 in include_from_node1 at loading.jl:128 in process_options at