Re: [julia-users] Why variables passed to this macro are referencing to the module?

2015-12-19 Thread David Moon
On Saturday, December 19, 2015 at 6:17:18 AM UTC-5, Tim Holy wrote: > > Presumably you need an esc around the exp. See the metaprogramming > chapter. > So the Julia maintainers never pulled my pull request from almost 2 years ago that fixed that?

[julia-users] Re: problem with a macro generating a type with inner constructor

2014-10-02 Thread David Moon
This would not have happened with my suggested reworking of macro hygiene, I think. I am not set up to test it right now.

[julia-users] Re: Why does this dispatch occur? (parametric types)

2014-07-04 Thread David Moon
Here is my take for what it is worth as an observer of the Julia language: I think your second method foo(x::Number) is unreachable because your first method foo{T:Number}(x::T) is more specific and there are no arguments to which only the second method is applicable. Having both methods would

Re: [julia-users] Re: Reducing algorithm obfuscation

2014-06-13 Thread David Moon
that it wouldn't be as trivial as it sounds. On Friday, 13 June 2014 02:01:28 UTC+1, David Moon wrote: Mike Innes' atsign with macro is good, but it would be better if it would iterate over the AST for its last argument and replace each occurrence of field with obj.field. That way there wouldn't be any

Re: [julia-users] Re: Reducing algorithm obfuscation

2014-06-12 Thread David Moon
Mike Innes' atsign with macro is good, but it would be better if it would iterate over the AST for its last argument and replace each occurrence of field with obj.field. That way there wouldn't be any unexpected assignments to fields which were not actually changed, and in general no wasted

[julia-users] Re: Strange macro behavior?

2014-06-04 Thread David Moon
I have a pending pull request #6910 to fix macros to behave as you expect, but until that gets integrated you will need to use the esc function in your macro to tell the macro system that x, y, and expr are in the macro caller's context, not the macro definition's context. There is no

Re: [julia-users] Reflection bug for parameterized types?

2014-06-02 Thread David Moon
in the sample code I supplied, all named T. It would have been clearer if I had given them distinct names, although that does not seem to be the usual practice in Julia. If you are interested in method reflection, I suggest looking at the output of methods() On Friday, May 30, 2014, David Moon

[julia-users] Re: Surprising behavior of singleton types

2014-05-31 Thread David Moon
On Saturday, May 31, 2014 1:08:29 PM UTC-4, Iain Dunning wrote: And I don't necessarily think this is wrong - look at the code it generates f{t,n}(::Type{Array{t,n}},::Array{t,n}) at none:3 f{t,n}(::Type{Array{t,N}},::Array{t,n}) at none:2 There is nothing to distinguish these two from a

[julia-users] Reflection bug for parameterized types?

2014-05-30 Thread David Moon
I noticed something strange about reflection on parameterized types. Consider this simplified code: julia type X{T : Number} x::T end julia f{T}(::X{T}) = 1 julia XT = methods(f).defs.sig[1] X{T} julia XT : X *false* julia X : XT true julia type Y{T} y::T end julia g{T}(::Y{T}) = 1 julia YT =

Re: [julia-users] Hygienic macros could be both better and simpler

2014-05-21 Thread David Moon
On Tuesday, May 20, 2014 4:53:38 PM UTC-4, Jameson wrote: Can you open a pull request? That's the best way to send a diff and have it evaluated. Thanks for the direction. I don't know much about Git, but I can probably figure out how to make a pull request. I am more of a Mercurial and

Re: [julia-users] Re: Why do macros use the @ sign?

2014-05-21 Thread David Moon
What bothers me about the @ is that it is too easy an answer for why if, while, for, try, yieldto, etc. are hard-wired into the language instead of being implemented as macros. Nobody wants to write @if x==y ; do this @else do that @end! But the real answer has got to be more interesting

[julia-users] Re: macro for generating functions with optional arguments

2014-05-09 Thread David Moon
Google groups wouldn't let me send this by email. I apologize if there is any duplication. On May 9, 2014, at 10:37 AM, Adam Smith wrote: My main reason for using eval() is to convert from a Symbol to a Type. If they supplied a full expression like (1 + 1) as the default value for an

[julia-users] Re: macro for generating functions with optional arguments

2014-05-09 Thread David Moon
Consider this: someval=foo def f(x::Int, @maybe y::String=someval) = (x,y) f(1) = (1, foo) someval=bar f(2) = (2, foo) # should be (2, bar) def g(x) = x + seen def h(x::String, @maybe y::String=g(x)) = y h(foo) # gives an error but should be foo seen See what I am getting at now about when

Re: [julia-users] I noticed there is no do while loop

2014-04-09 Thread David Moon
On Tuesday, April 8, 2014 7:17:18 PM UTC-4, Cameron McBride wrote: I've long enjoyed ruby's `loop` keyword for exactly this type of use. Too bad Julia doesn't have (full featured) macros so you could write loop yourself and just use it without first convincing a whole lot of people it's a

[julia-users] Typo in local variable name not detected

2014-03-07 Thread David Moon
In Julia-0.3.0-prerelease-d2d9bd93ed.app on Mac OS X 10.6: The following test case was boiled down from a much larger piece of code. function f(x) answer = false if (x 10) anwser = true end return answer end does not issue any warnings, and always returns

[julia-users] Re: Method redefinition only half works

2014-03-07 Thread David Moon
On Friday, March 7, 2014 11:24:51 AM UTC-5, Gunnar Farnebäck wrote: This is a long-standing issue. See https://github.com/JuliaLang/julia/issues/265 I didn't know about that, thanks for the pointer. In that issue I see: *malmaud https://github.com/malmaud *commented January 06,

Re: [julia-users] Hygienic macros could be both better and simpler

2014-02-26 Thread David Moon
I am not suggesting any change to :(x+y) so it would continue to be the same as quote x+y end. I think that would return Expr(internal_symbol(+, context), internal_symbol(x, context), internal_symbol(y, context)) to use a sketchy syntax that might not actually be valid Julia. I like using the

Re: [julia-users] Hygienic macros could be both better and simpler

2014-02-25 Thread David Moon
I should have said *quote* special form implicitly accessed a symbol context created each time a *named* function is entered or a top-level form is evaluated. Can't have anonymous functions implicitly create a symbol context or you can't use functionak programming inside of macros and you

[julia-users] Re: What is a Number?

2014-02-25 Thread David Moon
On Monday, February 24, 2014 6:54:59 AM UTC-5, andrew cooke wrote: Maybe (I don't think so) Julia needs some kind of concept like abstract methods, where you can name methods for Number that any subtype must implement? Long ago in Flavors this was called required methods. With multiple

[julia-users] Re: What is a Number?

2014-02-25 Thread David Moon
On Tuesday, February 25, 2014 7:14:37 AM UTC-5, David Moon wrote: The advantage of making it an explicit concept in the language, rather than just defining a method that signals an error, is that it can be checked at compile time. In Julia, compile time is load time. Specifically, after

[julia-users] Hygienic macros could be both better and simpler

2014-02-09 Thread David Moon
Hygienic macros could be both better and simpler. Julia's hygiene only works in simple cases, I think, and requires too much manual intervention. This is because it is done in the wrong place, in the output of macro expansion, so the macro expander has to guess the context of each symbol.