Reputation
11,206
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
20 47
Newest
 Nice Answer
Impact
~102k people reached

May
22
comment Simple problem about shadow symbols in multi-contexts
@rcollyer: I made it a community wiki, so pleas add as much as you want...
May
22
comment Simple problem about shadow symbols in multi-contexts
@rcollyer: question remains: do I type faster or am I better at copy and paste? :-) Thanks anyway...
May
22
comment Simple problem about shadow symbols in multi-contexts
@rm-rf: I could well imagine that this question has a duplicate, but I don't think the one you mention is one, woudn't you agree...
May
22
answered Simple problem about shadow symbols in multi-contexts
May
22
comment Checking from a preemptive evaluation whether a main evaluation is ongoing
I'm very late with this, but isn't that question superfluous: With Method->"Queued", the evaluation is queued to be evaluated using the main link, so there by definition isn't a (-nother) main evaluation running, and mainEvaluationOngoing always returns False, which is correct when interpreted as "is another main evaluation ongoing". Or am I missing something?
May
22
comment Correct behavior of lock file in hsqldb connection
The interesting fact about HSQL is that it is all java and comes ready to use with Mathematica. It can be used in a serverless mode much like sqlite but also has a server, which also can be started from within Mathematica. Especially for the serverless mode there is no need for any setup, you can just go along and play with the OPs code (for me it complains about the username setting, so you might want to delete that option). You will find that these files are locked after closing the connection (I just have tried on Windows), but that might depend on OS or filesystem in use...
May
22
comment How to replace a variable that was assigned a value before
... the reason for all that is that when the preemptive links interupt the queued evaluation they obviously see the current state of those Blocked symbols. This can cause problems which are very hard to detect and debug. I would wish that this simply wouldn't be the case, but probably that would make preemptive evaluations too expensive/complicated or whatever. This should, IMHO, certainly be better documented...
May
22
comment How to replace a variable that was assigned a value before
I think it is only safe as long as you don't use any Dynamic. As the FrontEnd itself might use these functionalities, it probably is only safe when used without a frontend altogether. Here is an example where you can see the problem: x=5;Dynamic[x -> DateString[], UpdateInterval -> 1] and then, in an extra cell: Internal`InheritedBlock[{Rule}, SetAttributes[Rule, HoldFirst]; Pause[5]]. I would in general be very cautious to change system symbols, even in Block and IneritedBlock, especially when also working with Dynamic...
May
22
revised A simple StringCases problem
added 530 characters in body
May
22
comment A simple StringCases problem
@Mr.Wizard: just in case you haven't found it, I just happend to struggle over it: (?ms) switches on "multiline mode" (m) and "match all characters including newlines" (s). I found that here: string patterns for perl users. The ?: does, to my understanding, prevent the match to be assigned to a field like $1. I have no good reference for that at this time...
May
22
revised A simple StringCases problem
removed superfluos .. after stringexpression as suggested by Mr.Wizard
May
22
comment A simple StringCases problem
@Mr.Wizard: ... and no, I don't understand why the regexp is slower, I guess it might be due to the \\s* which might be expensive and are not part of the Mathematica string expressions. I can ususally achieve regexps to do what I want but am not good enough to optimize them, so I well could be outperformed by auto-generated code. Honestly, I was quite surprised (and proud) that I got that monster working at first try :-)
May
22
comment A simple StringCases problem
@Mr.Wizard: yes, I also think that it is conceptually the same as your Shortest approach, which I think is more elegant, but I also don't have a well justified opinion about what is "better". I have only seen your suggestion after I finished my answer, but didn't want to delete it...
May
22
comment Correct behavior of lock file in hsqldb connection
"DatabaseLink`" connections in Mathematica are done via Java and it is the JRE which actually holds the file locks. To get rid of those locks you can e.g. use Needs["JLink"];UninstallJava[];. After that you should be able to delete the files. There might be ways to remove those locks without closing the JRE with according Java calls, but that I don't know. I think it is an oversight (=bug) in the implementation of the HSQL part of "DatabaseLink`" that a CloseSQLConnection doesn't remove these file locks, so you might want to contact WRI and see what they say...
May
22
comment Correct behavior of lock file in hsqldb connection
I think the problem of the OP is that what you suggest is not possible: Mathematica, or more precisely the JRE it uses for the database connection, still holds a file lock so you can't delete these files. Only when closing Mathematica (or the JRE) these file locks are removed and you can delete them. I think it is probably a bug in "DatabaseLink`" that these files remain locked after CloseSQLConnection[]...
May
22
revised How to replace a variable that was assigned a value before
added 23 characters in body
May
22
comment How to replace a variable that was assigned a value before
@bills: when you start to write code which you or even others try to reuse, then it is in general best to try to make as few changes to the global state of your session as possible. If you e.g. call a function which clears certain global variables with Clear that might not be what the caller expects and break the callers session/code. When writing packages and making use of name spaces, you also might need to take extra care to Clear the correct symbols.
May
22
revised How to replace a variable that was assigned a value before
added some remarks and examples
May
22
comment How to replace a variable that was assigned a value before
@Mr. Wizard: good point, it is somewhat more elegant, but as I have now added, it also is somewhat less explicit about how exactly it changes the evaluation order. Not a problem if you have a firm grasp of it, as I guess is the case for you :-). I added it to my answer...
May
22
answered How to replace a variable that was assigned a value before