All I am wanting to do something along the lines of...
some_file.out : ..... ver_$(basename $#).ver:
.....
The $# does not expand as expected but only in the rule header. Inside the body of the rule all uses of ver_$(basename $#).ver expand as desired. How would I modify this to make it work as desired?
You have ellipses eliding too many important parts of your example to provide a full solution. However, one option is to use static pattern rules, like this:
some_file.out : %.out : ver_%.ver
...
If that isn't sufficient you can use secondary expansion, but that's a bigger hammer.
Related
There are some forms in the tradition of Scheme that are named the same as more primitive forms but with a * appended as a suffix.
Some examples
let*
define*
Now for these derived forms the explanation is that you get visibility of your previous bindings
in the later bindings kind of a letrec style but creating one id at a time instead of all at once (?).
Now this pattern extends thought to other forms and some packages have custom macros with the * symbol as a suffix (define-ratbag*). Is this some implicit convention of the Scheme tribe, is this documented somewhere?
There are several things that a * suffix might mean:
sequential scoping like let*, as opposed to independent scoping like let. Examples: with-syntax* is like with-syntax, but each right-hand side is in the scope of previous clauses.
sequential effect as opposed to independent effect. Examples: parameterize* is like parameterize, but each parameter's new value is evaluated with the previous parameters updated to their new values; with-handlers* is like with-handlers, but each exception handler is called in a context with the previous exception handlers installed.
like the other thing, but multiple times. Examples: remove* is like remove, but removes all occurrences of the given element; regexp-match* is like regexp-match, but finds all matches.
like the other thing, but the final argument acts like a rest-argument. Examples append*, list*: (append* vss) is equivalent to (apply append vss).
like the other thing, but accepts multiple arguments. Examples: hash-set* is like hash-set, but accepts multiple key-value pairs.
like the other thing, but just a bit different. Examples: write-bytes-avail* is like write-bytes-avail, except it never blocks; date* is like date except it adds nanosecond and time-zone-name fields; call-with-input-file* is like call-with-input-file except closes the input port on escapes. In this usage, you can read * as Scheme/Racket's version of a prime suffix.
I am refactoring some business rule functions to provide a more generic version of the function.
The functions I am refactoring are:
DetermineWindowWidth
DetermineWindowHeight
DetermineWindowPositionX
DetermineWindowPositionY
All of them do string parsing, as it is a string parsing business rules engine.
My question is what would be a good name for the newly refactored function?
Obviously I want to shy away from a function name like:
DetermineWindowWidthHeightPositionXPositionY
I mean that would work, but it seems unnecessarily long when it could be something like:
DetermineWindowMoniker or something to that effect.
Function objective: Parse an input string like 1280x1024 or 200,100 and return either the first or second number. The use case is for data-driving test automation of a web browser window, but this should be irrelevant to the answer.
Question objective: I have the code to do this, so my question is not about code, but just the function name. Any ideas?
There are too little details, you should have specified at least the parameters and returns of the functions.
Have I understood correctly that you use strings of the format NxN for sizes and N,N for positions?
And that this generic function will have to parse both (and nothing else), and will return either the first or second part depending on a parameter of the function?
And that you'll then keep the various DetermineWindow* functions but make them all call this generic function?
If so:
Without knowing what parameters the generic function has it's even harder to help, but it's most likely impossible to give it a simple name.
Not all batches of code can be described by a simple name.
You'll most likely need to use a different construction if you want to have clear names. Here's an idea, in pseudo code:
ParseSize(string, outWidth, outHeight) {
ParsePair(string, "x", outWidht, outHeight)
}
ParsePosition(string, outX, outY) {
ParsePair(string, ",", outX, outY)
}
ParsePair(string, separator, outFirstItem, outSecondItem) {
...
}
And the various DetermineWindow would call ParseSize or ParsePosition.
You could also use just ParsePair, directly, but I thinks it's cleaner to have the two other functions in the middle.
Objects
Note that you'd probably get cleaner code by using objects rather than strings (a Size and a Position one, and probably a Pair one too).
The ParsePair code (adapted appropriately) would be included in a constructor or factory method that gives you a Pair out of a string.
---
Of course you can give other names to the various functions, objects and parameters, here I used the first that came to my mind.
It seems this question-answer provides a good starting point to answer this question:
Appropriate name for container of position, size, angle
A search on www.thesaurus.com for "Property" gives some interesting possible answers that provide enough meaningful context to the usage:
Aspect
Character
Characteristic
Trait
Virtue
Property
Quality
Attribute
Differentia
Frame
Constituent
I think ConstituentProperty is probably the most apt.
In a makefile, what's the difference between writing
define VAR =
...
...
endef
and writing
define VAR
...
...
endef
Notice that the latter is missing the = on the define line. Both are accepted by Gnumake, but they don't appear to exhibit the same behavior (for me, I find that using the latter does what I want it to).
When should you use which form?
There is no difference between them: both create recursive multi-line variable values.
There is ONE difference, though: the former version (with the equals sign) was introduced in GNU make 3.82 (released in 2010). If you're still using a version of GNU make before that, then this statement:
define FOO =
bar
enddef
creates a variable named FOO =, not FOO (which is probably why it doesn't appear to work for you).
The ability to add assignment operators here is really so you can use the other operators, such as :=, ?=, += with multi-line variables, which you didn't used to be able to do.
But the default if no operator is specified is and always has been, to create a normal recursive variable.
I have an issue.
I need to modify java "if/else/for/while/do statements should always use curly braces" coding rule into sonar Quality Profiles.
if/else/for/while/do statements should always use curly braces Not
using curly braces could be error-prone in some cases. For instance in
the following example, the two statements seems to be attached to the
if statement whereas this is the case only for the first one:
if (condition) // Non-Compliant
executeSomething();
checkSomething();
if (condition) { // Compliant
executeSomething();
}
checkSomething();
I need to extend it with adding one exclusion.
I should to keep this rule but add exception:
if (Logging.ENABLED) Logging.*
this expression should be ignored by this rule. Its mean that alarm should not appear when i write e.g.
if (Logging.ENABLED) Logging.logThrowable(LOG_TAG, e);
Could you be so kind how exactly step by step i can do it.
Thanks!
You can set an exclusion. See http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus#NarrowingtheFocus-IgnoreIssues ("Ignore Issues in Blocks" section). Start block can be "Logging.ENABLED" and End block can be "$". The only drawback for now is that it'll ignore all issues on this line. Feel free to vote for http://jira.codehaus.org/browse/SONAR-5122 if it's not ok with you.
Just wondering if it is possible, by some loophole, to define a method name that ends in a colon. The purpose it to make things look like this:
mymethod: arg1,arg2,arg3
It is technically possible to define a method with that name, but you can't call it like that because of syntax rules. (The colon is considered a different token.) You would have to do send('mymethod:', args), which defeats the purpose.