Thanks, Tamas.

I will look into this along the lines that you mention. When I tried 
previously to implement delayed evaluation using delaying and forcing 
procedures my sequence elements were still getting evaluated although I 
believe the delaying and forcing procedures were otherwise working in that 
delay postponed function evaluation by wrapping it in a procedure and a 
call to the forcing procedure could subsequently evaluate the delayed 
function. But I will have another look as I must have been mistaken. I just 
wasn't sure if there was something about how Julia evaluates that prevented 
a procedural approach to delayed evaluation (and hence the use of macros 
for lazy.jl etc.).


So there are three reasons actually I was curious about this.

First I am learning Julia and I was trying to get a sense of Julia's 
evaluation model sort of step by step.

Second (and relatedly) I am trying to get a better sense of the need and 
the utility of macros and meta-programming--what do they make possible that 
is otherwise not possible?  Also at the moment for the way that I am going 
to use Julia, clarity in the code is a top priority (over fanciness). So if 
I can write something that is easier to read (for a novice) then that is an 
approach that I prefer to one that is more sophisticated but also more 
obscure. One of the things I like about Julia is that generally it is quite 
easy to read.

Third I am interested in working with delayed evaluation and was trying to 
get a better sense of that also. I'd like to understand how the macro 
implementation is better than the procedural implementation.

You mention that there would be a lot of boilerplate code without macros . 
. . . It seemed to me that once you have delaying and forcing procedures 
there is not big difference in delayed evaluation compared to where it is 
implemented using macros. I am interested in better understanding your 
comment . . . .

Thanks,
Mark

On Friday, July 17, 2015 at 9:49:48 AM UTC-4, Tamas Papp wrote:
>
> Of course. Eg 
>
> delayed1 = function() 
>   print("evaluating!\n") 42 
> end  force(f::Function) = f()  force(delayed1) 
>
> You just need the macros for the syntactic sugar, bookkeeping, 
> etc. 
>
> Any intermediate Scheme textbook provides a lot of examples on how 
> to do these things with closures.   
>
> I am curious why you want to do it without macros, though; you 
> just get a lot of boilerplate code. BTW, there aren't a lot of 
> macros in Lazy.jl either. 
>
> Best, 
>
> Tamas 
>
> On Fri, Jul 17 2015, Mark S <[email protected] <javascript:>> wrote: 
>
> > Hello, 
> > 
> > I am interested in the delayed evaluation implementations like 
> > Lazy.jl  (one-more-minute) and LazySequences.jl (dcjones).  Both 
> > of these use  Julia's macros facilities. 
> > 
> > Is it possible to implement delayed evaluation without using 
> > macros? 
> > 
> > Thanks for any leads or good references on this. 
> > 
> > Mark 
>
>

Reply via email to