Jump to content

  • Log In with Google      Sign In   
  • Create Account






*Yawn*

Posted by ApochPiQ, 21 May 2009 · 44 views

I've spent the few rare free moments I have working on Epoch lately; there's a healthy set of things getting checked off the R7 work list (see previous entry) and progress is definitely being made.

There's still a few kinks to work out, but infix operators are now working more or less perfectly. Along with a few other tweaks, this changes the code from something nasty and littered with function calls, to this:

//
// TASKS.EPOCH
//
// Demonstration of the multiprocessing capabilities of Epoch
//


entrypoint : () -> ()
{
task(asyncjob1)
{
pi_task()
}

task(asyncjob2)
{
pi_task()
}

task(complexjob)
{
acceptmsg
(
compute(integer(a), integer(b), integer©, string(d)) =>
{
message(sender(), completed(a * b + c, d))
}
)
}

message(asyncjob1, calculate("ignored"))
message(asyncjob1, ignoredmessage("foo", "bar", 42))

message(asyncjob1, calculate(10000.0))
message(asyncjob2, calculate(50000.0))

message(complexjob, compute(5, 4, 2, "Filler"))

debugwritestring("Please wait, async tasks running...")


integer(baz, 42)
debugwritestring("Main task: " . cast(string, baz))

responsemap(resulthandler)
{
result(real(foo)) => { debugwritestring("Pi result: " . cast(string, foo)) }
completed(integer(a), string(b)) => { debugwritestring(b . cast(string, a)) }
}

acceptmsg(resulthandler)
acceptmsg(resulthandler)
acceptmsg(resulthandler)
}


pi_task : () -> ()
{
acceptmsg(calculate(real(limit)) => { message(sender(), result(pi(limit))) } )
}


pi : (real(denominator_limit)) -> (real(retval, 0.0))
{
real(denominator, 1.0)
boolean(isplus, true)

do
{
real(div, 4.0 / denominator)

if(isplus == true)
{
retval = retval + div
}
else
{
retval = retval - div
}

isplus = not(isplus)
denominator = denominator + 2.0

} while(denominator < denominator_limit)
}



Since the lack of good infix operators was pretty much the number one complaint about the language, I trust that this will boost your enthusiasm accordingly [wink]




August 2014 »

S M T W T F S
     12
3456789
10111213141516
17181920212223
242526 27 282930
31      
PARTNERS