<< Back to previous view

[ALGOM-1] Add conditionals stratements to domonad forms Created: 06/Jan/12  Updated: 05/Feb/14  Resolved: 05/Feb/14

Status: Closed
Project: algo.monads
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Roman Gonzalez Assignee: Konrad Hinsen
Resolution: Completed Votes: 0
Labels: None
Environment:

The extension was developed in Mac OS X Lion


Attachments: File monadic-if-else.diff    
Patch: Code

 Description   

I implemented a patch that would allow us to do conditionals on domonad macros

Example:

(domonad monad-m
[a (action 1)
:if (= a 3)
:then [
result (action c)
]
:else [
result (action d)
]]
result)

Conditional blocks can be nested.

One gotcha one has to be aware of is: you may use bindings from a conditional branch in the m-result sexp as long as that branch gets called, given that one doesn't know for sure which branch is going to be called, you should set the same bindings on both branches.

The patch code is on: github.com/roman/algo.monads

I didn't do a pull request given that you need to this first.

NOTE: I've added this feature in some other projects I've been working on (parser combinators) and is working perfectly so far, there is tests in the patch but I wanted to give you that safe net as well.



 Comments   
Comment by Roman Gonzalez [ 10/Jan/12 12:28 AM ]

Adding support for monadic conditionals on the domonad macro

Comment by Konrad Hinsen [ 05/Feb/14 5:22 AM ]

This has been accepted long ago: https://github.com/clojure/algo.monads/commit/d9b13dcc57be0d11934441c2dc7a9b287385f435

Generated at Sat Oct 25 22:13:27 CDT 2014 using JIRA 4.4#649-r158309.