[julia-users] Re: Julia and Object-Oriented Programming

2015-10-24 Thread Abe Schneider
Swift has an interesting take on composition via protocols (note, it also has the concept of single inheritance): https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html it avoids copying anything into the child class, but rather sets up

Re: [julia-users] Julia and Object-Oriented Programming

2015-10-23 Thread Abe Schneider
An OO approach is really just specifying an interface in a formal manner. The second you write any type of interface, you always risk making a choice that will haunt you down the road. I don't see the difference between: class Foo { float getX() { ... } float getY() { ... } } and: type

Re: [julia-users] Julia and Object-Oriented Programming

2015-10-23 Thread Abe Schneider
Ah, okay, that is different then. What's the advantage of creating a new method versus copying the fields? I would imagine there is a penalty with each deference you have to follow in order to make that work. I'm not familiar with Scala, so sorry if I'm telling you something you > know, but

Re: [julia-users] Julia and Object-Oriented Programming

2015-10-22 Thread Abe Schneider
I think this is generally in-line with what I've been advocating for, and not that different from Scala's mix-ins: trait Wheel { // ... } trait Frame { // ... } class Unicycle extends trait Wheel, Frame { // ... } is essentially doing the same thing (i.e. copying the member variables

[julia-users] Re: Julia and Object-Oriented Programming

2015-10-20 Thread Abe Schneider
As for class composition, this is how Scala does it: http://www.scala-lang.org/old/node/117 I've previously suggested introducing a `trait` label as to keep type and dispatch information separate. Thus you could do: trait A x::Int64 y::Int64 end trait B z::Int64 end type foo(A, B) <:

Re: [julia-users] Re: Julia and Object-Oriented Programming

2015-10-19 Thread Abe Schneider
dispatch > approach seems to me far better at addressing program maintainability and > extensibility than classes ever were. Julia does still need a way of > talking about interfaces and protocols in the language itself, but that's > ongoing design problem, not a fundamental issue. >

Re: [julia-users] Re: Julia and Object-Oriented Programming

2015-10-19 Thread Abe Schneider
UTC-4, Tim Holy wrote: > > On Sunday, October 18, 2015 07:38:24 PM Abe Schneider wrote: > > > Julia isn’t object-oriented, and will probably never be. But that > doesn’t > > > make it less powerful :) > > > > Of course it doesn't make it less powerful, bu

Re: [julia-users] Re: Julia and Object-Oriented Programming

2015-10-19 Thread Abe Schneider
ted such a macro awhile ago (maybe a year?), and it was met with disapproval. Not that that should stop anyone from writing it, but it was deemed un-Julian (at least my take on people's responses). I think this can be seen as a type of mix-in similar to what Ruby and Scala do. > > O

[julia-users] Re: Julia and Object-Oriented Programming

2015-10-18 Thread Abe Schneider
> > > But I agree with Tobias and Simon - there is very little reason to try to > make Julia more object-oriented. All the power you get from OO is still > there, but you might need to think a little differently to harness it. If > you have a concrete problem, along the lines of “this is how

[julia-users] Re: Julia and Object-Oriented Programming

2015-10-18 Thread Abe Schneider
On Sunday, October 18, 2015 at 9:44:21 PM UTC-4, vav...@uwaterloo.ca wrote: > > Going a bit on a tangent, I claim that object-oriented programming, at > least as embodied in C++, is not really suitable for scientific computing > and in fact has led certain codes to go astray. > C++ is

[julia-users] Re: Julia and Object-Oriented Programming

2015-10-18 Thread Abe Schneider
I would say that the module is closest to a c++ namespace, which itself can be thought of as a static class. Note, however, that in both cases you can't really have separate instances. Because of the desire to separate dispatch from type information, Julia doesn't really follow the OOP

Re: [julia-users] Re: macros generating macros in modules

2015-04-05 Thread Abe Schneider
That's definitely an option, though it seems sub-optimal to me if it's possible to automate it from a user's perspective. It may be that it just isn't possible, but if so, is it because it's something the language doesn't currently support or does it go against the philosophy of the language?

Re: [julia-users] Re: macros generating macros in modules

2015-04-05 Thread Abe Schneider
to concretely suggest. On Saturday, April 4, 2015 at 9:39:57 PM UTC-5, Abe Schneider wrote: I don't understand how what I'm trying to do falls outside the domain of transforming code. My main goal is to take a user-defined grammar and create relevant code. More to the point, I think

[julia-users] macros generating macros in modules

2015-04-04 Thread Abe Schneider
I should start off, not entirely sure this is an okay thing to do with Julia. Suppose I want to create a macro that generates another macro, I can write: macro meta_macro(x) quote macro foo(y) $x+y end end end and then call it and the generated macro: @meta_macro(5)

[julia-users] Re: macros generating macros in modules

2015-04-04 Thread Abe Schneider
` would generate the `@grammar` macro with the static list it already has plus whatever else the user adds in. Which works, except for the whole module issue. Thanks, A On Saturday, April 4, 2015 at 12:41:27 PM UTC-4, Patrick O'Leary wrote: On Saturday, April 4, 2015 at 9:04:10 AM UTC-5, Abe

Re: [julia-users] Re: macros generating macros in modules

2015-04-04 Thread Abe Schneider
special_foo( $(QuoteNode(syntax_tree) ) end end On Sat, Apr 4, 2015 at 8:05 PM Abe Schneider abe.sc...@gmail.com javascript: wrote: The issue I'm dealing with is that I have a macro that I want to pass a list of functions that the macro can employ for parsing grammars

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-24 Thread Abe Schneider
(:block, rule.action)) push!(code, Expr(:escape, Expr(:(=), dot, fn))) end end which seems to do the trick. On Monday, March 23, 2015 at 8:00:23 AM UTC-4, Abe Schneider wrote: Okay, I think I almost have a solution. I now collect all the actions from the rules with the function

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-23 Thread Abe Schneider
doAction(expr) return parseDefinition(..., expr, ...) end On Sun, Mar 22, 2015 at 8:15 AM Abe Schneider abe.schnei...@gmail.com http://mailto:abe.schnei...@gmail.com wrote: I'm in the process of trying to figure out how to do something similar to that, but it's unfortunately not easy. I

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-23 Thread Abe Schneider
. so for the example above, rather than directly assigning expr.args[2] into rule.action, you would return the equivalent expression (quote; rule.action = $(expr.args[2]); end) that do that operation at runtime On Sun, Mar 22, 2015 at 11:01 PM Abe Schneider abe.schnei...@gmail.com http

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-22 Thread Abe Schneider
I'm in the process of trying to figure out how to do something similar to that, but it's unfortunately not easy. I was hoping that there might be a method to insert an expression into the AST without an eval required, as it would greatly simplify the code Jameson suggested using the `insert`

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-22 Thread Abe Schneider
Sorry, when I said AST, I meant the code that gets executed. A macro, at least the way I think about it, is inserting the resulting Expr into the main AST. My macro's primary role is to create a dictionary mapping symbols to `Node`s. Each Node has an associated action (passed in with the curly

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-21 Thread Abe Schneider
that takes `val` in as an argument and returns some new expression (which you can then combine with other expressions before returning the whole thing from the main macro) On Wed, Mar 18, 2015 at 9:51 AM Abe Schneider abe.schnei...@gmail.com http://mailto:abe.schnei...@gmail.com wrote

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-21 Thread Abe Schneider
I have, but it's not entirely clear to me how I would use it in this particular case. The code in question is being called from a function (which while ultimately is being called from a macro) doesn't directly return an expression in this case. Specifically, I have something that looks like:

Re: [julia-users] Re: inserting an Expr into AST via macro

2015-03-19 Thread Abe Schneider
with other expressions before returning the whole thing from the main macro) On Wed, Mar 18, 2015 at 9:51 AM Abe Schneider abe.schnei...@gmail.com http://mailto:abe.schnei...@gmail.com wrote: Unfortunately my solution only works if you pass in an expression directly. If you try something like

Re: [julia-users] inserting an Expr into AST via macro

2015-03-18 Thread Abe Schneider
UTC-4, Isaiah wrote: See http://docs.julialang.org/en/release-0.3/manual/metaprogramming/#interpolation On Mar 18, 2015 8:08 AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: If I do something simple like: macro test() :(parsefloat(3.1459)) end @test() # 3.1459 everything

[julia-users] inserting an Expr into AST via macro

2015-03-18 Thread Abe Schneider
If I do something simple like: macro test() :(parsefloat(3.1459)) end @test() # 3.1459 everything works as expected. However, if I try this instead: macro test2(ex) ex end @test2(:(parsefloat(3.1459))) # :(parsefloat(3.1459)) Not what I expected, but it makes sense what's happening:

[julia-users] Re: inserting an Expr into AST via macro

2015-03-18 Thread Abe Schneider
2: ASCIIString 3.1459 typ: Any So I can rewrite the macro as: macro test2(ex) ex.args[1] end which appears to work: @test2(:(parsefloat(3.1459))) # 3.1459 On Wednesday, March 18, 2015 at 8:08:35 AM UTC-4, Abe Schneider wrote: If I do something simple like: macro test

[julia-users] Re: inserting an Expr into AST via macro

2015-03-18 Thread Abe Schneider
did before.in the main macro. On Wednesday, March 18, 2015 at 9:30:32 AM UTC-4, Abe Schneider wrote: After some thought, I realized that the easiest way to unquote is to reach inside the Expr and pull out what is needed. If I do a dump of `ex` I get: Expr head: Symbol quote args

Re: [julia-users] creation of parametric variables in a macro

2015-03-07 Thread Abe Schneider
). - alternatively, you could recurse through their expr code and replace all variables of the form `_(\d+)` with :(children[\1]) - On Fri, Mar 6, 2015 at 9:30 PM Abe Schneider abe.schnei...@gmail.com http://mailto:abe.schnei...@gmail.com wrote: Hmmm, good to know. Thank you. The rationale

Re: [julia-users] creation of parametric variables in a macro

2015-03-06 Thread Abe Schneider
it more succinctly by templating the redundant parts. if you want a set or numbered list, use a set or number list. variables are bad at that sort of task. whereas an Array is very good at it. On Fri, Mar 6, 2015 at 8:05 AM Abe Schneider abe.sc...@gmail.com javascript: wrote: I'm trying

[julia-users] creation of parametric variables in a macro

2015-03-06 Thread Abe Schneider
I'm trying to create a set of variables (_1, _2, ...) from items within a list in a macro. I have a (much) condensed version of the code: macro testfn() quote i = 1 value = [1, 2, 3] $(Expr(:(=), Expr(:symbol, Expr(:string, _, :i)), :value)) println(_1)

[julia-users] assignment operator

2014-10-18 Thread Abe Schneider
I was recently thinking about the nature of `=` of not being an operator. The reason given is that it sets the binding of the variable, rather than the value. It seems like it would be nice to have an operator that dealt with values rather than bindings. The reason being: (a) if it's an

[julia-users] Abstract types with fields

2014-09-06 Thread Abe Schneider
Don't worry, I'm not re-opening the currently debated issue . It occurred to me a while ago that it should be possible to support this feature without any changes to the language itself. Instead I've created the macros `@_abstract`, `@_type`, and `@_immutable`. The idea is that `@_abstract`

[julia-users] Re: Function with state calling stateless version, or the other way around?

2014-08-25 Thread Abe Schneider
You can think of a Task like a function that maintains state automatically. However, instead of using returning values with 'return x', you use 'produce(x)' instead. This will cause execution of the Task to pause until it is called again. Tasks are called with the 'consume' function, which

[julia-users] Function with state calling stateless version, or the other way around?

2014-08-23 Thread Abe Schneider
It may be worth having both around. If you wrap the stateless versions with something that keeps state, users get the choice of which one to use. For example, you could use Tasks to create generators that produce the next value. The Task will keep the state for you, which allows you to keep

[julia-users] Grammatical Evolution

2014-08-15 Thread Abe Schneider
For anyone who is interested, I've been working on a Grammatical Evolution (GE) [Conor Ryan, JJ Collins and Michael O'Neill, 1998] http://en.wikipedia.org/wiki/Grammatical_evolution#cite_note-1 library: https://github.com/abeschneider/GrammaticalEvolution It is not quite ready to reach version

[julia-users] Re: Equivalent of c++ functor objects, std::bind, and lambdas

2014-08-15 Thread Abe Schneider
Here's a quick test: function make_counter(x) return (delta) - begin x += delta x end end c0 = make_counter(0) c1 = make_counter(0) c0(1) # 1 c1(1) # 1 c0(1) # 2 c1(1) # 2 So it looks like they don't share the bound 'x' variable. On Friday, August 15, 2014 11:50:03 AM UTC-4, Noah

Re: [julia-users] Using a callback from a macro

2014-08-09 Thread Abe Schneider
), which is why they generally don't have access to the environment. On Friday, August 1, 2014, Abe Schneider abe.sc...@gmail.com javascript: wrote: I tried a second approach where instead of keeping a function around I keep just the symbol. I have a `transform` function that applies

[julia-users] Passing an expression from a macro to a function

2014-08-03 Thread Abe Schneider
I found one previous conversation related to this, but unfortunately the answer didn't work for me. Hopefully I'm not asking an obvious question. Suppose I have some macro: macro mytest(fn::Symbol, ex::Expr) quote $(esc(fn))($ex) end end and I have some function that takes in the

Re: [julia-users] Passing an expression from a macro to a function

2014-08-03 Thread Abe Schneider
. --Tim On Sunday, August 03, 2014 11:46:43 AM Abe Schneider wrote: I found one previous conversation related to this, but unfortunately the answer didn't work for me. Hopefully I'm not asking an obvious question. Suppose I have some macro: macro mytest(fn::Symbol, ex::Expr

[julia-users] Using a callback from a macro

2014-08-01 Thread Abe Schneider
I've come across a problem where I have macro to define a grammar (similar to how PEGParser currently works): @grammar foo begin rule[fn] = some + (rule | test) end where the `[fn]` next to the rule defines a function to call on the results (in this case it's an expansion). The issue is

[julia-users] Re: Using a callback from a macro

2014-08-01 Thread Abe Schneider
)) wherever you were previously using $fn On Friday, August 1, 2014 11:38:44 AM UTC-4, Abe Schneider wrote: That's correct, I'm generating code that keeps a pointer to that function to call later on. If I do that, I have the type `esc(fn)` in the macro (this is what I get when printing it out

[julia-users] Re: Using a callback from a macro

2014-08-01 Thread Abe Schneider
the macro, I could then just get the macro that way. I'm guessing Julia doesn't currently have this functionality, but would it be something possible to add? On Friday, August 1, 2014 12:22:46 PM UTC-4, Abe Schneider wrote: I think the problem is that I'm not accessing it directly through

[julia-users] overloading an abstract interface

2014-07-26 Thread Abe Schneider
I have a pattern that has come up multiple times where in a module I might have some function `foo` which will call some other function `bar` on a given type. The exact function `bar` isn't defined yet because it is defined by the user-type. The problem I run into is that if `bar` is defined

[julia-users] Re: overloading an abstract interface

2014-07-26 Thread Abe Schneider
Thank you. If I do: function testmodule.bar(baz::ConcreteBaz) return baz.value end it works. I'm guessing this means that Julia won't look outside of the namespace for a function. It hadn't occurred to me that writing: function module.fn() # ... end would work. On Saturday, July 26,

[julia-users] A julia version of diy-lisp (python project)

2014-07-20 Thread Abe Schneider
If you're interested, PEGParser includes a lisp grammar in the examples section. The transform converts to Julia expressions, but that can easily be changed.

[julia-users] Sorting behavior

2014-07-20 Thread Abe Schneider
It wasn't obvious to me initially why `sort` wasn't working for me (strings and composite types). On further investigation it looks like that it only works for single-dimension arrays -- which makes sense. However, if I type: lst = [a b c] sort(lst) I get an error. The answer is that it's of

Re: [julia-users] PEG Parser

2014-07-13 Thread Abe Schneider
4, 2014, at 11:09 AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: I got sidetracked by a couple of other things, but the parser is now updated with a bunch of bug fixes. I have a preliminary CSV and graphdot parser (very reduced from the full grammar). I'm starting to put together

[julia-users] Re: PEG Parser

2014-07-04 Thread Abe Schneider
files. After a few more tests are written, I'm getting ready to officially call a version 0.1. On Thursday, June 5, 2014 6:56:37 AM UTC-4, Abe Schneider wrote: I also forgot to push the changes last night. On Wednesday, June 4, 2014 11:01:33 PM UTC-4, Abe Schneider wrote: After playing

Re: [julia-users] type design question

2014-06-22 Thread Abe Schneider
://github.com/JuliaLang/julia/issues/4935. On Jun 21, 2014, at 9:59 AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: I think that's a fair point (though I may disagree that it's non-othogonal). My main point is that you are already implicitly using a hierarchical structure

Re: [julia-users] type design question

2014-06-21 Thread Abe Schneider
, 21. Juni 2014 03:43:57 UTC+2 schrieb Abe Schneider: I agree, I think it's the best solution given the tools (and what I'm going to use for my code). However, it still feels more like a hack around the design than good programming practice. On Friday, June 20, 2014 5:41:02 PM UTC-4, Spencer

Re: [julia-users] type design question

2014-06-21 Thread Abe Schneider
more than why not? On Jun 21, 2014, at 8:45 AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: After some thought, it occurred to me that with the grouping you suggested, you are really implementing a type of inheritance. If you rename your sub-type as 'parent' you have: type

Re: [julia-users] type design question

2014-06-20 Thread Abe Schneider
are in the current view private. You might be also interested in https://github.com/JuliaLang/julia/issues/6975 where we discuss how to define interfaces more formally as it is done now. Cheers, Tobi Am Freitag, 20. Juni 2014 04:15:21 UTC+2 schrieb Abe Schneider: Okay, so

Re: [julia-users] type design question

2014-06-20 Thread Abe Schneider
It's good to see other people want multiple inheritance too :). One thing I haven't seen discussion yet is using Scala's method of constructors to make deal with the fields and MI. It seems like abstract types could be equivalent to Scala traits (if abstract types allowed fields), and regular

Re: [julia-users] type design question

2014-06-20 Thread Abe Schneider
I was thinking something along those lines, but as was pointed out, you would have to also create the constructors. Unfortunately, I'm on my phone right now, so I can't effectively post code. I was thinking of a 'mixin' macro which would create a new type (with constructor): @mixin Foo : Bar

Re: [julia-users] type design question

2014-06-20 Thread Abe Schneider
I was thinking something along those lines, but as was pointed out, you would have to also create the constructors. Unfortunately, I'm on my phone right now, so I can't effectively post code. I was thinking of a 'mixin' macro which would create a new type (with constructor): @mixin Foo : Bar

Re: [julia-users] type design question

2014-06-20 Thread Abe Schneider
. Most importantly, it does it in really easy-to-reason-about way, without adding any tricky edge cases or complicated rules for developers to understand. peace, s On Fri, Jun 20, 2014 at 3:57 PM, Abe Schneider abe.sc...@gmail.com javascript: wrote: I was thinking something along those

[julia-users] type design question

2014-06-19 Thread Abe Schneider
I'm trying to figure out the best way to factor code that consists of repeated modules which all share some common attributes. Specifically, if I have (very abbreviated from actual code): abstract NNModule type LinearModule : NNModule weight::Array{Float64} output::Array{Float64} end type

Re: [julia-users] type design question

2014-06-19 Thread Abe Schneider
this line type LinearModule : NNModule weight::Array{Float64} output::Array{Float64} end type SigmoidModule : NNModule output::Array{Float64} end On Thu, Jun 19, 2014 at 8:18 AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: I'm trying to figure out the best way to factor

Re: [julia-users] animation using Gtk+/Cairo

2014-06-17 Thread Abe Schneider
Abe Schneider wrote: I was looking for a way to display a simulation in Julia. Originally I was going to just use PyPlot, but it occurred to me it would be better to just use Gtk+ + Cairo to do the drawing rather than something whose main purpose is drawing graphs. So far

Re: [julia-users] animation using Gtk+/Cairo

2014-06-17 Thread Abe Schneider
AM, Abe Schneider abe.sc...@gmail.com javascript: wrote: Thank you everyone for the fast replies! After looking at ImageView and the sources, here's the solution I came up with: w = Gtk.@Window() | (body=Gtk.@Box(:v) | (canvas=Gtk.@Canvas(600, 600)) | showall function redraw_canvas

Re: [julia-users] animation using Gtk+/Cairo

2014-06-17 Thread Abe Schneider
(canvas, myscene) A On Tuesday, June 17, 2014 1:16:11 PM UTC-4, Jameson wrote: Yes. Although I think the draw...do function is actually redraw...do (this is actually a shared interface with Tk.jl, although I recommend Gtk :) Sent from my phone. On Tuesday, June 17, 2014, Abe Schneider abe.sc

[julia-users] animation using Gtk+/Cairo

2014-06-16 Thread Abe Schneider
I was looking for a way to display a simulation in Julia. Originally I was going to just use PyPlot, but it occurred to me it would be better to just use Gtk+ + Cairo to do the drawing rather than something whose main purpose is drawing graphs. So far, following the examples on the Github

Re: [julia-users] Faster sub-strings

2014-06-11 Thread Abe Schneider
julia typeof(ans) SubString{ASCIIString} (constructor with 1 method) Which is totally understandable, as there seems to be almost zero documentation about them. Would you mind opening an issue about that? Cheers, Kevin On Wed, Jun 11, 2014 at 5:08 AM, Abe Schneider abe.sc...@gmail.com

Re: [julia-users] Faster sub-strings

2014-06-11 Thread Abe Schneider
I think that could also work. I prefer keeping that same syntax for regular strings (the square-brackets make things easier to read). I'm assuming strings don't normally return views because their contents could change, thus copies are safer. That's why I'm suggesting creating an

[julia-users] Re: PEG Parser

2014-06-05 Thread Abe Schneider
I also forgot to push the changes last night. On Wednesday, June 4, 2014 11:01:33 PM UTC-4, Abe Schneider wrote: After playing around with a bunch of alternatives, I think I've come up with decent action semantics: @transform name begin label = action end For example, a simple graph

[julia-users] Re: Strange macro behavior?

2014-06-04 Thread Abe Schneider
/testscript.jl, in expression starting on line 9 but if I define foo in the module (the commented out line), I get: fn1 = 3 fn2 = 2 On Tuesday, June 3, 2014 9:59:25 PM UTC-4, Abe Schneider wrote: I have a macro that is defined in a module that creates a dictionary of anonymous functions

[julia-users] Re: Strange macro behavior?

2014-06-04 Thread Abe Schneider
I should add, I suspect that 'esc' can only be used in a quote block, so I tried this instead: macro wrapexpr(expr) quote ($(esc(x)), $(esc(y))) - $(esc(expr)) end end But get: ERROR: x not defined On Wednesday, June 4, 2014 11:44:43 AM UTC-4, David Moon wrote: I have a pending

[julia-users] Re: Strange macro behavior?

2014-06-04 Thread Abe Schneider
I got it to work with: macro wrapexpr(expr) x = :x y = :y quote $(esc(quote ($x, $y) - $expr end)) end end I think the problem before was that the entire anonymous function has to be escaped. I also don't claim to understand hygiene well enough to really understand what that means.

Re: [julia-users] Re: PEG Parser

2014-06-04 Thread Abe Schneider
. There's a bunch of test files in the DataFrames.jl/test directory. -- John On May 27, 2014, at 3:49 PM, Abe Schneider abe.sc...@gmail.com javascript: wrote: I don't know how the speed of the parser will be compared to DataFrames -- I've done absolutely no work to date on profiling the code

Re: [julia-users] parsers?

2014-06-03 Thread Abe Schneider
better if they can be immutable. thanks, andrew On Saturday, 31 May 2014 21:10:37 UTC-4, Abe Schneider wrote: I should add that PEGParser's code is fairly new and untested (besides having an uninspired name). I'm also hoping to have better action semantics soon. On Saturday, May 31

Re: [julia-users] parsers?

2014-06-03 Thread Abe Schneider
, andrew cooke wrote: On Tuesday, 3 June 2014 08:16:49 UTC-4, Abe Schneider wrote: Currently it only handles strings. The reason is that PEG theoretically have infinite look-ahead. I think this can be made a little better by having a stream that loads data on-demand. In general, I think PEG's

[julia-users] Strange macro behavior?

2014-06-03 Thread Abe Schneider
I have a macro that is defined in a module that creates a dictionary of anonymous functions. These anonymous functions wrap arbitrary code which I pass in. If I pass in simple pieces of code (e.g. just returning a simple value), my test script everything works as expected. However, if I make

Re: [julia-users] parsers?

2014-05-31 Thread Abe Schneider
I should add that PEGParser's code is fairly new and untested (besides having an uninspired name). I'm also hoping to have better action semantics soon. On Saturday, May 31, 2014 2:17:27 PM UTC-4, andrew cooke wrote: https://groups.google.com/d/msg/julia-users/t56VxOX1vvk/nszQYWP_pm4J

[julia-users] Re: PEG Parser

2014-05-27 Thread Abe Schneider
I don't know how the speed of the parser will be compared to DataFrames -- I've done absolutely no work to date on profiling the code, but I thought writing a CSV parser was a good way to test out code (and helped find a bunch of bugs). I've also committed (under examples/) the CSV parser. The

[julia-users] Re: PEG Parser

2014-05-27 Thread Abe Schneider
I'll take a look. I found the full grammar here: http://www.graphviz.org/doc/info/lang.html Unfortunately I have very little free time (most of the work was done during vacation), but it shouldn't be too difficult to implement. On Monday, May 26, 2014 4:35:52 PM UTC-4, Miles Gould wrote:

[julia-users] PEG Parser

2014-05-25 Thread Abe Schneider
I wrote a quick PEG Parser for Julia with Packrat capabilities: https://github.com/abeschneider/PEGParser It's a first draft and needs a ton of work, testing, etc., but if this is of interest to anyone else, here is a quick description. Grammars can be defined using most of the standard EBNF

[julia-users] Design question

2014-05-24 Thread Abe Schneider
I'm currently working on a problem where I have a tree structure composed of: type Node value label children end which I want to traverse and have different functions called depending on the value of label. Normally I would just sub-type Node. However, the results are coming from a

[julia-users] Re: logical indexing... broadcasting

2014-05-16 Thread Abe Schneider
I might try something like (note the code code is written for clarity, not for compactness or completeness): function encode_name(name::String) if name == setosa return [1 0 2]; elseif name == versicolor return [2 1 0]; else return [0 2 1]; end end output = map(encode_name,

[julia-users] Re: Macro question

2014-05-15 Thread Abe Schneider
the example again to check it's behaving in the expected way? On Thursday, 15 May 2014 12:29:13 UTC+1, Abe Schneider wrote: As an experiment I wrote a simple macro to set a variable: macro createVar(name, value) eval(quote $name = $value; end) end which works as expected

[julia-users] Re: Macro question

2014-05-15 Thread Abe Schneider
to `expr = (foo = 5)`, *not* `expr = :(foo = 5)` expr == 5 If you do want `createVar` to return an expression, it should be a function instead of a macro. Maybe try running the example again to check it's behaving in the expected way? On Thursday, 15 May 2014 12:29:13 UTC+1, Abe Schneider

[julia-users] Re: tree style

2014-05-14 Thread Abe Schneider
Just in terms of implementing trees, I would do something like: abstract Node; type Leaf : Node value::Float64; end type Branch : Node left::Node; right::Node; end This should allow you to write methods that target either branch or leafs accordingly: function