Random_seed behaves differently when called as a function or as a subroutine. I am not sure if this is the expected behaviour. I am running yorick 2.2.02x. The following demonstrates this difference (starting in a fresh yorick):

Code:

> random(1)[0.0891647]> random_seed,.123> random(1)[0.162779] > random_seed(.123)> random(1)[0.0891647] //since gives initial random number, it is like seed is out of range.> random_seed,.123> random(1)[0.162779] //works when called as a subroutine.

I would have guessed that calling random_seed as a function would return the current random seed.

The problem is that Y_random_seed drops all its arguments and left nothing on top of the stack so when you call it as a function (without storing the result in a variable) the interpreter "displays" the result (the topmost stack item) which is the function itself and thus re-execute random_seed without any argument this time which reset the seed to a default value as you correctly guessed.

The fix is easy: just discard:

Code:

Drop(nArgs);

at the last line of function Y_random_seed in std1.c (line number 1120). Then the result of calling random_seed will be its argument (whatever it is). Another possibility could be to push a boolean (scalar int) to indicate whether the call was successful or not.

I am not allowed to push changes into Yorick repository so I left Dave decides if it is worth fixing this bug...

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum