Skip to content

Conversation

@jasonjckn
Copy link

I removed all the force and delays in clarsec/monad.

I added a new way to handle forward references, all the logic is isolated into a macro called m-lazy.

Examples of using m-lazy:

Ex1.
(def foo)
(def bar (m-lazy foo))
(def foo identifier)
(parse bar "tada")

Ex2.
(def recur1
(<|> (symb "foo")
(braces (m-lazy recur1))))

Ex3. function call with an argument
(defn recur2 [x](|> %28symb x%29
%28braces %28m-lazy %28recur2 x%29%29%29))

How does it work?
m-lazy converts symbol references to var references
E.g. in (m-lazy foo) symbol foo is converted to var namespace/foo
The var is dereferenced during parsing stage, as oppose to monad binding phase.

Hope you like it :)
Cheers, Jason

@jasonjckn
Copy link
Author

you'll want to increment version, this change is backwards incompatible

@jasonjckn jasonjckn closed this Jun 4, 2011
@jasonjckn jasonjckn reopened this Jun 4, 2011
@devn
Copy link
Owner

devn commented Jun 5, 2011

Very cool, Jason. Awesome work and thank you for sharing your solution.

Devin Walters

On Saturday, June 4, 2011 at 12:49 PM, jasonjckn wrote:

I removed all the force and delays in clarsec/monad.

I added a new way to handle forward references, all the logic is isolated into a macro called m-lazy.

Examples of using m-lazy:

Ex1.
(def foo)
(def bar (m-lazy foo))
(def foo identifier)
(parse bar "tada")

Ex2.
(def recur1
(<|> (symb "foo")
(braces (m-lazy recur1))))

Ex3. function call with an argument
(defn recur2 [x](|> %28symb x%29
%28braces %28m-lazy %28recur2 x%29%29%29))

How does it work?
m-lazy converts symbol references to var references
E.g. in (m-lazy foo) symbol foo is converted to var namespace/foo
The var is dereferenced during parsing stage, as oppose to monad binding phase.

Hope you like it :)
Cheers, Jason

Reply to this email directly or view it on GitHub:
#2

devn added a commit that referenced this pull request Apr 25, 2012
Alternative method of lazy evaluation
@devn devn merged commit 00c9926 into devn:master Apr 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants