Reply to topic  [ 9 posts ] 
Three new features available 
Author Message
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post Three new features available
I have added three new features to yorick. All are best used sparingly.

    1. include, include1

    The include function now accepts string or char arrays, which it treats as text streams, as it would the text stream from a file. Note that debugging information will not be worth much in this case, as there is no useful file name. Like a file, the input must be a set of complete yorick statements; there is no way to begin input in one call and continue it in the next.

    There is a new function, include1, which parses a string or char array until it reaches the end of the first executable statement. Instead of executing that statement, it returns the *main* function which would have been executed.

    2. vopen, vclose, vsave, openb

    Yorick now supports "in-memory" text or binary files. You can use the new vopen function to return a read-only file handle into an existing string or char array. Either a string (one line per array element) or char array (as returned by textload, for example) can be associated with a text file handle; binary file handles may only be associated with char arrays. You can also use vopen to create a text or binary file handle for writing. In this case, you need the vclose function to convert your file handle into a string array for a text handle or a char array for a binary handle. (Note that the strchar function converts string arrays to char arrays, if you need to create a char array from a text file handle.)

    The new vsave function creates a char array containing a self-describing file, as if by createb. The openb function now accepts a char array instead of a filename in order to give you back a file handle from which you can read back the variables you saved using vsave.

    3. wrap_args

    You can now write interpreted functions which have full control over their argument lists, so that their behavior can match any "special effects" you can get by writing a compiled function. In particular, your interpreted function can retrieve the name of the variable which was passed to it (or determine that an argument was an expression); it can accept arbitrary keywords (not just a predefined set); it can write output back to any positional argument which was a simple variable reference (not previously available for .. arguments retrieved by next_arg()); and it can find how many actual arguments were supplied (so it can distinguish between explicitly provided nil arguments and omitted arguments).


As usual, the help function provides details for all these features.

All three support a new version of mpy which I hope to release in the next month or two. (The vsave function uses wrap_args, the in-memory files were necessary to implement include, and, finally, MPI locks up the filesystem if a million copies of mpy all need to read std.i when they start.)


Sun Jul 12, 2009 1:37 pm
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
..


Last edited by sguieu on Wed Nov 04, 2009 11:26 am, edited 1 time in total.



Wed Nov 04, 2009 11:23 am
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
Nice functions,

Are they yet available ? I have the last 2.1.05 version of Yorick available on SF, I cannot find them. Are they on CVS ? Maybe I ask something evident sorry.


Wed Nov 04, 2009 11:25 am
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
Forget about it, I run :
cvs -d:pserver:anonymous@yorick.cvs.sourceforge.net:/cvsroot/yorick login
cvs -z3 -d:pserver:anonymous@yorick.cvs.sourceforge.net:/cvsroot/yorick co -P yorick

and I have it now. That was a problem with my cvs.


Wed Nov 04, 2009 11:35 am
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
wrap_args

It seems that the keyword arguments does not work if there is no positional argument after :

Code:
> func test(args) { args(-); args("color"); args(1);}
> wrap_args, test
> test, 2, color="red"
[]
[]
2


but

Code:
> test, 2, color="red", 5
["color"]
"red"
2


Wed Nov 04, 2009 11:59 am
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
One more thing, I hope it can help for the next official depositary :

in the vsave function on the 6th line :
Code:
eq_nocopy, a, args(i);


'i' is not defined in the function it is '1' instead. It makes the function to fail.

And, why when you type "> args" (in debug mode) it return an error message instead of returning > info, args like any other yorick objects? Is there any reasons for that or it is a feature?


Wed Nov 04, 2009 2:32 pm
Profile
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post 
I think I found the bug for wrap_args

On ywrap_f_eval function in the file wrap.c at the line ~186

e.i :
Code:
if (me[k].ops || k+1>=argc) continue;


Should be

Code:
if (me[k].ops || k>=argc) continue;


Other wise the last keyword argument is skipped if there are no positional argument after.

Maybe I should post this in the "bug" forum ?


Thu Nov 05, 2009 3:15 pm
Profile
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post 
Yes, probably should have reposted in Bugs forum.

Don't bother now -- you had everything right, and I just committed your bug fixes to CVS. The print bug is even fixed (at least you left me one thing to find on my own, although gcc printed a warning I hadn't noticed).


Mon Nov 09, 2009 9:27 pm
Profile
Yorick Guru

Joined: Sat Jan 22, 2005 2:44 pm
Posts: 86
Location: Pasadena, CA
Post 
First toughts on this:

vopen, vclose, vsave...

This might help me deal with some of the
odd data I sometimes get from hardware
(12-bit packed data, ... compressed data.)
If I am reading the documentation correctly
I can use this as a form of "reshape." So far
I have been reading/writing this data using
home-made plugins, but this might make it
easier (as I have mentioned here, reshape
as a memory leak on the SGI altix systems
I work with.)

help, wrap_args;
/* DOCUMENT wrap_args, interpreted_function
.....
This rather arcane feature permits you to pass an
argument of the form f.x, where f is a file handle, to
functions like dimsof or structof without triggering a
read of the file.
.....
Excellent! I have been faced with that same problem for
a while (and coded my way around it.) When sampling
huge file, and hopping around in a non-predictable
manner, you do not want to re-read data if you do not
need to ... This should help. At least that is my
"yorick-for-dummies" understanding, and I have
yet to play with it.

Thank you.


Thu Nov 12, 2009 9:22 am
Profile YIM
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.