Difference between 'scope:setting(Key, Value)' and 'setting(scope:Key, Value)' - module

In SWI-Prolog's settings library, is there a different between the following:
scope:set_setting(Key, Value) and set_setting(scope:Key, Value)
scope:setting(Key, Value) and setting(scope:Key, Value)
:- scope:setting(Key, Type, Default, Doc) and :- setting(scope:Key, Type, Default, Doc)
In addition: can scope be anything but user and a currently loaded module name?

Difference between scope:setting(Key, Value) and setting(scope:Key, Value)
settings are local to the module and they cannot be called as a predicate and can only be declared as a directive.
setting(Key, Value) only enumerates the settings of the current module. All settings can be enumerated using setting(Module:Name, Value). This predicate is deterministic if Name is ground.
set_settings changes the settings.

Related

Intellij Idea location of generated constructor

I've been using the Intellij Idea constructor generator as per https://www.jetbrains.com/help/idea/generating-constructors.html and it's been working fine except for the location of generated constructors.
"The generated constructors are inserted at the points defined in the Order of Members section of the Code Style settings. By default, the code generator places constructors after the fields."
The Code Style settings doesn't have anything about Order of Members that I can find, and the code generator seems to be just putting constructors wherever the cursor happens to be at the time.
How do you get the code generator to put them in the right place?
If the cursor is located in a position where IntelliJ can validly insert a constructor then IntelliJ will insert the generated constructor in that position.
If the cursor is not located in a position where IntelliJ can validly insert a constructor then IntelliJ will insert the generated constructor according to the "Order of Members".
To verify this ...
Place your cursor on the class name and then invoke the constructor generator (Code > Generate ... > Constructor) and the generated constructor will be inserted according to "Order of Members"; typically after member declarations and any other constructors already present in the class.
Place your cursor on an empty line within the class and then invoke the constructor generator (Code > Generate ... > Constructor) and the generated constructor will be inserted at your cursor location.
Have you looked under Settings -> Editor -> Code Style -> Java? There, you'll find an "Arrangement" tab that lets you define the order of fields, methods and constructors:

Must Kotlin Local Functions be Declared Before Use

In this simple code example...
fun testLocalFunctions() {
aLocalFun() //compiler error: unresolved reference at aLocalFun
fun aLocalFun() {}
aLocalFun() //no error
}
Elsewhere in the language, using a function before definition is allowed. But for local functions, that does not appear to be the case. Refering to the Kotlin Language Specification, the section on Local Functions is still marked "TODO".
Since this sort of constraint does not hold for other types of functions (top-level and member functions), is this a bug?
(Granted, local variable declarations must occur before use, so the same constraint on local functions is not unreasonable. Is there a definitive, preferably authoritative source document that discusses this behavior?)
It's not a bug, it is the designed behavior.
When you use a symbol (variable, type or function name) in an expression, the symbol is resolved against some scope. If we simplify the scheme, the scope is formed by the package, the imports, the outer declarations (e.g. other members of the type) and, if the expression is placed inside a function, the scope also includes the local declarations that precede the expression.
So, you can't use a local function until it's declared just like you cannot use a local variable that is not declared up to that point: it's just out of scope.

How can I make IntelliJ refactor->rename parameter only rename the local version of it? (Kotlin)

I have an overridden function, where the parameter has a different name in the overridden version.
Original function:
fun hookEvent(event: Event) { ... }
overridden function:
fun hookEvent(e: Event) { ... }
This gives me a warning that it can cause problems when using named arguments.
When I select Refactor->Rename, and try to rename 'e' (in the overridden function) to 'event', IntelliJ searches my entire project and finds every single place where I have overridden the original function, and tries to rename the parameter in all of them. Then I get conflicts because in some of those places, 'event' is already a local variable in those functions.
I only want it to rename that particular instance of the parameter, in that particular overridden function. How?

In Emacs how do I make a local variable safe to be set in a file for all possible values

In Elisp I have introduced for a special custom mode a variable like:
(defvar leo-special-var "")
(make-variable-buffer-local 'leo-special-var)
Now I set this variable in files I with the lines (in the file to edit):
# Local Variables:
# leo-special-var: "-d http://www.google.com.au"
# End:
And I want to consider this variable as "safe for all its values. That's why safe-local-variable-values doesn't help. Instead I tried (in the lisp code):
# setting the symbol property of the variable
(put 'leo-special-var 'safe-local-variable 'booleanp)
but without success. Do I do something wrong when setting the symbol property? Or is there another way?
You want to use
(put 'leo-special-var 'safe-local-variable #'stringp)
to say that it is safe as long as it's a string.
If you really want to state that it is safe for all values then use this:
(put 'leo-special-var 'safe-local-variable (lambda (_) t))
The function to test safety here returns non-nil for any value.
(But I'd think that you probably do not want to state that a variable is safe for any value.)
It's in the manual: (elisp) File Local Variables
You can specify safe values for a variable with a
`safe-local-variable' property. The property has to be a function of
one argument; any value is safe if the function returns non-`nil' given
that value. Many commonly-encountered file variables have
`safe-local-variable' properties; these include `fill-column',
`fill-prefix', and `indent-tabs-mode'. For boolean-valued variables
that are safe, use `booleanp' as the property value. Lambda
expressions should be quoted so that `describe-variable' can display
the predicate.
When defining a user option using `defcustom', you can set its
`safe-local-variable' property by adding the arguments `:safe FUNCTION'
to `defcustom' (*note Variable Definitions::).

Modeshape configuration - combine XML + programmatic?

I have configured a Modeshape workspace on my dev box using XML, pointing to:
workspaceRootPath="C:/jcr/modeshape/dev/..."
I will deploy to Linux with a workspace mounted on a different volume:
workspaceRootPath="/jcr/modeshape/prod/..."
Is it possible to use an environment variable to configure this or do I need to resort to programmatic configuration? Is there an approach recommended by the Modeshape team?
Thanks
If you're using later versions of ModeShape, you can use a variable in the configuration file that will be replaced at configuration load time with the value of the System property of the same name. For example, if you use the following:
workspaceRootPath="${myWorkspaceDirectory}"
and have a System property "myWorkspaceDirectory" set to "/foo/bar", then when ModeShape loads the configuration it will resolve the variable into the equivalent:
workspaceRootPath="/foo/bar"
Of course, the variable can be just a part of the attribute value, and you can even use multiple variables (as long as they're not nested). For example, this is valid, too:
workspaceRootPath="${my.system.root.path}/modeshape/${my.system.deploymentType}"
Finally, the grammar of each variable is:
"${" systemPropName { "," systemPropName } [ ":" defaultValue ] "}"
This allows 1 or more System property names and an optional default value to be specified within a single variable. The System property names are evaluated from left to right, and the first to have a corresponding real system property will be used. Here's another contrived example:
workspaceRootPath="${my.system.path1,my.system.path2,my.system.path3:/default/path}/modeshape/${my.system.deploymentType}"