error in declaring higher-order functions in XPath 3.0: must declare return type? - basex

Following #DimitreNovatchev's article Programming in XPath 3.0, and using BaseX GUI as the test environment, I tried some of the examples that define functions that accept functions as parameters. E.g. with
let $compose :=
function($f as function(), $g as function())
(The rest of the code isn't relevant to this error, but you can see it as the third example under Function Composition.)
I get this error from BaseX:
Error:
Stopped at 43-compose.xpath, 2/39:
[XPST0003] Expecting 'as', found ','.
The point where the error was detected was on the second line, just before the comma. Apparently, the processor expects the $f parameter declaration to say not just that $f should be a function, but also the return value of the function.
I don't know whether it's right for BaseX to expect that or not. Presumably, Dimitre's examples tested successfully before he made that presentation at Balisage. Maybe something changed in the XPath 3.0 spec between that article and when BaseX was released?

OK, found the answer. I got an evaluation key for Saxon EE, so I was able to try another processor. For future reference, this was the command line:
C:\Program Files\Saxon>java -cp saxon9ee.jar net.sf.saxon.Query -s:"input.xml" -
q:"ex5.xpath" -qversion:3.0
Note that -qversion:3.0 is currently required in order to get any 3.0 functionality.
Saxon throws an error at the same point, but gives a helpful suggestion on how to fix it:
Error on line 2 column 39 of ex5.xpath:
XPST0003 XQuery syntax error near #... function($f as function(), $#:
function() is no longer allowed for a general function type: must be function(*)
I changed function() to function(*) wherever a general function type was wanted, and the errors went away, both in BaseX and in Saxon.
So apparently BaseX was correct (but Saxon's error message was more helpful, as is often the case!). Sounds like something did change in the spec recently. I haven't been able to figure out what the relevant change was, from the change log. But regardless of what changed, the spec currently says that a FunctionTest must have either a * within the parentheses, or an as after them. (This applies to declarations of parameters that are functions, but does not apply to inline functions themselves.)

Related

Error on one page that does not appear anywhere else

Hi so my wordpress site has just started acting up, I am not sure if its an update that has caused this but only on this one page I am getting this error regarding
Notice: Array to string conversion in /customers/c/1/7/veganantics.co.uk/httpd.www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/ImageAttachmentSchema.php on line 95
I can't seem to find the issue, I have tried replacing the file with a new core file and the error is still there, would really appreciate some help
This is the page: https://veganantics.co.uk/vegan-gifts/
Thank you
Ash
The theme, a plugin or some custom code is probably using the wp_calculate_image_sizes filter and returning an array instead of a string.
Do a text search on your install and look for wp_calculate_image_sizes. The function that you need to find will look similar to
add_filter('wp_calculate_image_sizes', 'something');
Explanation:
ImageAttachmentSchema.php on line 95 is calling wp_get_attachment_image_sizes which must be a string.
wp_get_attachment_image_sizes is returning wp_calculate_image_sizes( $size_array, $image_src, $image_meta, $attachment_id ) which again must be a string.
wp_calculate_image_sizes returns a filtered value, and that's the only place where such an error (array instead of a string) can happen. So, if the filter incorrectly returns an array, it bubbles up to the function that you see in the error log.

I started to using mothur version - v.1.36.1-, but I got some error messages (shown below). How I can overcome this?

I start the Mothur Tutorial (https://www.mothur.org/wiki/MiSeq_SOP). But from the beginning, I got some error messages when I create " make.file "in mothur*(Error commands are shown below). I changed parameters but the result was negative. How can I solve this problem?
****mothur > make.file(inputdir=MiSeq_SOP, type=fastq, prefix=stability)
Setting input directory to: MiSeq_SOP/
prefix is not a valid parameter.
The valid parameters are: type, seed, inputdir, and outputdir.
[ERROR]: did not complete make.file.****
Actually, the prefix parameter is a valid parameter in mothur. Personally, I have never encountered a problem with using a prefix for the make.file command, but your command should be valid.
You could test if your inputdir is specified correctly (the mothur error and warning messages are not necessarily the most clear ones). If this works as well, I suggest that you well document this behaviour and send it to the mothur team (in my experience, they are quite responsive and ready to help).

How to insert print for each function of C language for debugging?

I am studying and debugging one software. There are thousands of functions in this software. I plan to add printf() at the entry and exit point of each function. It will take a lot of time.
Is there one tool/script to do this?
I may use '__cyg_profile_func_enter'. But it can only get address. But I have to run another script to get function name. I also hope to get value of input parameters of this function too.
You should give a try to AOP : Aspect Oriented Programming. Personnaly I've only tried with Java and Spring AOP but there's an API for C too : AspectC (https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/home). From what I've seen, it's not the only one.
From what I've red about this library, you can add an pointcut before compiling with AspectC :
// before means it's a before function aspect
// call means it's processed when a function is called
// args(...) means it applies to any function with any arguments
// this->funcName is the name of the function handled by AspectC
before(): call(args(...)) {
printf("Entering %s\n", this->funcName);
}
(not tried by myself but extracted from the reference page https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/tutorial)
This is only a basic overview of what can be done and you still have to deal with the compilation (documented in the page linked before) but it looks like it could possibly help you. Give a try with a simple POC maybe.

Wondering about qooxdoo syntax/parsing

I found two lines in my code.
test = new qx.ui.form.RadioGroup;
I am wondering, if the missing () might cause issues or should maybe raise a warning in the generator or the lint job.
qx.ui.form.RadioGroup;
I think it might be worth reporting it as a "statement without effect" in lint.
mck89's comment is the answer (I wonder why so many people put valid answers in comments...):
You don't need the parens, and new qx.ui.form.RadioGroup is a syntactically correct expression, equivalent to adding a pair of empty parens. (There are some checkers that will warn about this, like I believe JsLint, but qooxdoo doesn't ... :).
In your particular case, the code will also run successfully in the browser, as RadioGroup permits empty constructor args; you can use .add() later to add items to the group.

Ruby C Extension using Singleton

I only wanted to allow one instance of my C extension class to be made, so I wanted to include the singleton module.
void Init_mousetest() {
VALUE mouseclass = rb_define_class("MyMouse",rb_cObject);
rb_require("singleton");
VALUE singletonmodule = rb_const_get(rb_cObject,rb_intern("Singleton"));
rb_include_module(mouseclass,singletonmodule);
rb_funcall(singletonmodule,rb_intern("included"),1,mouseclass);
### ^ Why do I need this line here?
rb_define_method(mouseclass,"run",method_run,0);
rb_define_method(mouseclass,"spawn",method_spawn,0);
rb_define_method(mouseclass,"stop",method_stop,0);
}
As I understand it, what that line does is the same as Singleton.included(MyMouse), but if I try to invoke that, I get
irb(main):006:0> Singleton.included(MyMouse)
NoMethodError: private method `included' called for Singleton:Module
from (irb):6
from C:/Ruby19/bin/irb:12:in `<main>'
Why does rb_include_module behave differently than I would expect it to? Also any tangential discussions/explanations or related articles are appreciated. Ruby beginner here.
Also it seems like I could have just kept my extension as simple as possible and just hack some kind of interface later on to ensure I only allow one instance. Or just put my mouse related methods into a module... Any of that make sense?
according to http://www.groupsrv.com/computers/about105620.html the rb_include_module() is actually just Module#append_features.
Apparently Module#include calls Module#append_features and Module#included. So in our C code we must also call included. Since clearly something important happens there.

Resources