59,017 reputation
6175266
bio website mathprogramming-intro.org
location St. Petersburg, Russia
age 38
visits member for 2 years, 9 months
seen 10 hours ago

Ok, an obligatory note: opinions expressed here are mine and not those of my employer.


Sep
7
comment How to properly handle mutual imports of multiple packages?
@Rojo Needs, not only its context will be added again to the $ContextPath, but also the contexts of all those packages it was importing via the second argument of BeginPackage. At some point, it took me a while to decipher this behavior, since it looks like you call Needs on one context and get several contexts added to the $ContextPath. Of course, this seems natural in retrospect, but this is still something worth knowing.
Sep
7
comment How to properly handle mutual imports of multiple packages?
@Rojo Martin listed the main difference, which is, private vs public package import. Appending Needs leads to private import, meaning that the context of the imported package won't be kept on the context path after this one had been loaded. There is a more subtle (related) difference. When you indicate extra contexts via the second argument of BeginPackage, they are cached internally. Imagine that you load a given package itself privately, then neither its context nor contexts of those packages it imports would remain on the $ContextPath. However, if you later load this package via ...
Sep
6
comment Why does the name of a pattern affect the result of a transformation rule?
There can also be an issue with the ordering, since it is different for b,a and b,c, and Times is Orderless. Some unwanted reorderings may happen based on variable names.
Sep
6
comment Why does the name of a pattern affect the result of a transformation rule?
You are using immediate rules, so there is a chance that b or c had prior values. Try with delayed rules instead, they scope their variables properly.
Sep
6
revised How to properly handle mutual imports of multiple packages?
added 3 characters in body
Sep
6
answered How to properly handle mutual imports of multiple packages?
Sep
6
comment Why modules with no variables?
No, of course I agree. Your comment actually made me realize that the problem of side effects is largely avoided in the large-scale mma programming simply because pass-by-reference semantics is not natural in mma, and requires Hold-attributes, so this is not how parameters are passed most of the time. So, the biggest problem of having functions dependent on the context on the large scale isn't actually there. And side effects on the scale of individual functions can only increase the complexity so much.I still prefer doing without them for better testability and composability though.
Sep
4
comment Improving the source-code indentation in Wolfram Workbench
@R.M Thanks, I will really appreciate your help with this. Will ping you when I get to it, hopefully very soon.
Sep
4
comment Improving the source-code indentation in Wolfram Workbench
@R.M Superb idea! I had to be brief (by my standards :-) ) in my SE post, and I can include some more stuff in the blog post. The only thing is, I want to improve the formatter first - currently there are too many unfixed bugs and cases it does not handle correctly. Also, I want to do a serious refactoring and introduce a tiny DSL which would allow the user to write small scripts to customize the formatter. But this won't take that long, and meanwhile I will make the post on Bessel functions, which is really mostly ready. I can make the formatter my second blog post, after that one.
Sep
4
comment Improving the source-code indentation in Wolfram Workbench
Related question. Actually, improving my code formatter presented there is on the top of my to-do list. It will be possible to customize it to format in very different styles. It is so far FE-based only, but it should be possible to port it to say Java and make an Eclipse plugin to be used in WB. I may consider doing this if there is enough interest in the community.
Sep
4
comment Why modules with no variables?
+1, indeed I use this as a convention. But, I think that side effects are still side effects, even when they are made with local variables and not easily observable from the outside. To me, the main difference that side effects bring is that the pieces which form the body of Module are generally no longer meaningful in isolation, and this impairs testability. Of course, it may not matter much on a small scale of a single function, but the style of thinking is still different. I agree that side effects would affect code much more had the pass-by-reference been used more frequently.
Sep
3
comment Where in the documentation can I find a list of function argument types?
No problem :). Just thought it would be useful to mention the general reason / mechanism.
Sep
3
comment Where in the documentation can I find a list of function argument types?
Related question
Sep
3
comment Where in the documentation can I find a list of function argument types?
This has also a considerable impact on performance, see e.g. this answer. This may become relevant in the context of typing and type-checking, since sometimes type-checks using PatternTest can bring an unacceptable performance hit. Finally, truly strong typing should not IMO use PatternTest since this makes it dependent on main evaluator, while using x_h makes this quite rigid and independent on anything outside the pattern-matcher.
Sep
3
comment Where in the documentation can I find a list of function argument types?
+1, nice explanation. I would probably add that the behavior of functions with HoldAll attribute is but one example of a more general and simple principle: patterns of type x_h are purely syntactic and the fact of their match can be established by the pattern-matcher alone, while the presence of Condition and PatternTest signal the call to the main evaluator. That is, every pattern having them as its part(s) induces sub-evaluations during the pattern-matching, just to establish the fact of the match.
Sep
2
comment How to make use of NumericQ[x] = True (and use it safely)?
You may also want to look at this discussion
Aug
31
comment How to compile effectively?
@R.M Ok, sounds cool. Thanks for the warm wishes. I did work with Fredholm determinants quite a bit, b.t.w.
Aug
31
comment How to compile effectively?
@R.M I can also look at it and see if I can do something, if this doesn't take too long. But right now I am on vacation and having a very limited internet access and computing resources (old and slow laptop I took with me on the road). I can look at it when I am back, in a couple of weeks, why don't you send me an email then?
Aug
31
comment How to compile effectively?
@R.M I wasn't alas working with Tracy-Widom, since my work was focused on the distributions of smallest eigenvalues for certain random matrices (Wishart matrices, approximating Dirac operator in QCD), and in a certain scaling limit which is different from Tracy-Widom. And right now, I don't even have Mehta book, so my memories of that stuff are fading :-) (I left academia 4 years ago and I only worked on RMT during my post-doc, my PhD was in Quantum Field Theory, only slightly related to RMT). But, why don't you post this as a question and list your specific difficulties?
Aug
30
comment How to improve the performance of solutions to Project Euler (#39)?
@rcollyer Because otherwise the compiler would assign some default type (integer or real number, forgot which), and then will report type conflict when first seeing it being a list rather than a number.