POSIX-Compliant Way to Scope Variables to a Function in a Shell Script

It is normally done with the local keyword, which is, as you seem to know, not defined by POSIX. Here is an informative discussion about adding ‘local’ to POSIX. However, even the most primitive POSIX-compliant shell I know of which is used by some GNU/Linux distributions as the /bin/sh default, dash (Debian Almquist Shell), supports … Read more

Are idempotent functions the same as pure functions?

An idempotent function can cause idempotent side-effects. A pure function cannot. For example, a function which sets the text of a textbox is idempotent (because multiple calls will display the same text), but not pure. Similarly, deleting a record by GUID (not by count) is idempotent, because the row stays deleted after subsequent calls. (additional … Read more

Pass object to javascript function

The “braces” are making an object literal, i.e. they create an object. It is one argument. Example: function someFunc(arg) { alert(arg.foo); alert(arg.bar); } someFunc({foo: “This”, bar: “works!”}); the object can be created beforehand as well: var someObject = { foo: “This”, bar: “works!” }; someFunc(someObject); I recommend to read the MDN JavaScript Guide – Working … Read more

How to deal with name/value pairs of function arguments in MATLAB

I prefer using structures for my options. This gives you an easy way to store the options and an easy way to define them. Also, the whole thing becomes rather compact. function example(varargin) %# define defaults at the beginning of the code so that you do not need to %# scroll way down in case … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)