u3: backports u3v_soft_peek()

This commit is contained in:
Joe Bryan 2022-11-17 14:56:52 -05:00
parent d0dc3e7710
commit 4d57c3c9a0
2 changed files with 31 additions and 0 deletions

View File

@ -77,6 +77,11 @@
u3_noun
u3v_peek(u3_noun hap);
/* u3v_soft_peek(): softly query the reck namespace.
*/
u3_noun
u3v_soft_peek(c3_w mil_w, u3_noun sam);
/* u3v_poke(): insert and apply an input ovum (protected).
*/
u3_noun

View File

@ -216,6 +216,32 @@ u3v_peek(u3_noun sam)
return u3n_slam_on(fun, sam);
}
/* u3v_soft_peek(): softly query the reck namespace.
*/
u3_noun
u3v_soft_peek(c3_w mil_w, u3_noun sam)
{
u3_noun gon = u3m_soft(mil_w, u3v_peek, sam);
u3_noun tag, dat;
u3x_cell(gon, &tag, &dat);
// read failed, produce trace
//
// NB, reads *should not* fail deterministically
//
if ( u3_blip != tag ) {
return u3nc(c3n, gon);
}
// read succeeded, produce result
//
{
u3_noun pro = u3nc(c3y, u3k(dat));
u3z(gon);
return pro;
}
}
/* u3v_poke(): insert and apply an input ovum (protected).
*/
u3_noun