Are tuple modules an officially documented feature of the language? - erlang

EDIT: Steve Vinoski kindly provided in the comments the official name for those : tuple modules.
My original question remains though: are tuple modules officially documented by the OTP team? And are they expected to remain supported in the future?
Original question:
Consider the following erlang module:
-module(foo).
-compile(export_all).
new(Bar) -> {foo, Bar}.
get({foo, Bar}) -> Bar.
I was quite amazed to see it allows the following (using erlang 19.1):
2> Foo = foo:new(bar).
{foo,bar}
3> Foo:get().
bar
which differs quite strongly from the usual way of calling a module's function.
As far as I can tell, it seems to be a remnant of parametrized modules, which have been deprecated since R16; and I can't find anything in the official documentation stating this is a supported, stable feature of the language.
My question is: is this a documented feature of the language? And if yes, where?

As far as I know this is an undocumented remnant of parameterized modules and exists to prevent legacy code from breaking. I imagine it is intended chiefly to prevent Mochiweb from breaking, as I can't think of any other serious libraries that make use of parameterized modules.
I can't locate any documentation on it and it doesn't seem to be a subject of current consideration. There was an announcement I cannot locate (but found references to, but not links) that claimed this would be documented, but that was quite a while ago.
The release readme for R16B where parameterized modules were removed mentions this:
OTP-10616
The experimental feature "parameterized modules" (also
called "abstract modules") has been removed. For applications that
depends on parameterized modules, there is a parse transform
that can be used to still use parameterized modules.
The parse transform can be found at: github.com/erlang/pmod_transform
That issue number does not appear in OTP's issue tracker anymore, and I can't even find an occurrence of "parameterized module" or "tuple module" anywhere in OTP's Jira instance. So I'm assuming this is an undocumented legacy crutch and nothing more.

Related

Where is Microsoft.FSharp.Text.ArgParser?

The old FSharp Powerpack seems to be obsolete, and most of its components have moved to other projects. Where can I find the ArgParser module? Is it still maintained?
An improved version of ArgParser is maintained as part of ExtCore. If you're looking for a library of extended library functions, ExtCore is an excellent choice.
If you don't mind a few more files, just put Arg.fs and Arg.fsi into your projects. They're self-contained; I did it here without issue.
As the comment above suggested, you should give UnionArgParser a try (see their docs at http://nessos.github.io/UnionArgParser/). It is a well-maintained and fully declarative alternative; that is much better than ArgParser.

OCRopus documentation?

Is there a documentation for ocropus?
I am looking for an explanation for the functions like:
make_SegmentPageByRAST():
segment()
RegionExtractor():
setPageLines()
extract()
Thank you.
A requirement of Lua API for OCRopus has been filed in the bug-tracker list of the project.
They will soon be releasing this documentation in the next beta release(expected).
First, note that you can use the command line tools without actual Lua programming.
A good place to see how to use ocroscript is to look at the test cases in
ocroscript/tests and the command line driver scripts in ocroscript/scripts.
Note: The Lua bindings follow the C++ API very closely (the binding is mostly
automatic), so C++ and Lua documentation are pretty much the same problem.

How do I implement an F# Read Eval Print Loop (REPL)?

I would like to add an F# REPL to my application for live debugging purposes. I am looking at the source code for fsi.exe (F# Interactive) and there is a ton of stuff going on that looks like it pokes around with F# compiler internals. I cannot get this same code to compile in the context of our application because of this.
Is there a nice simple example of implementing an F# REPL somewhere? I would have hoped for this to be fairly easy.
The short answer is that F# (unfortunatelly) doesn't currently provide any API for hosting F# Interactive in your applications. There are a lot of people asking for this - see for example this SO question.
There are essentially two things you could do about that:
You can modify the open-source release and compile fsi.exe as some DLL library that would provide the API you need. This isn't simple task - F# Interactive is tightly bound with the compiler (it compiles code you enter on the fly), but it should be doable to encapsulate the types implementing REPL into some type you could call (But you cannot just take some file out of it - you need to compile entire F# to get this working).
You can run fsi.exe as a separate process as Visual Studio does and send commands to it using standard input/output. You can get some more flexibility by loading your library when fsi.exe starts. The library could use .NET Remoting to connect back to your application and expose some data.
Unfortunatelly, these two options are probably the only things you can do at the moment.
EDIT I was thinking that I already answered this question somewhere (perhaps in email), but couldn't
find it! Thanks to Mauricio who found the exact duplicate (even with my duplicate answer... Doh!)
I've written a series of blog posts about using the open source F# interactive executable inside and WPF application.
The code base is available on github - https://github.com/oriches/Simple.Wpf.FSharp.Repl
The series of blog posts are:
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-1.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-2.html
http://awkwardcoder.blogspot.co.uk/2013/12/simple-f-repl-in-wpf-part-3.html
The final post is to follow soon.

How to enforce Delphi Coding Standards

I want to enforce coding standards for our Delphi codebase.
A few colleagues have suggested Code Healer and Pascal Analyzer. I've had a look at these tools and they aren't suitable.
I was hoping to be able to do the same thing that CheckStyle for Java or StyleCop for C# can do
Some newer editions of Delphi offer Audits and Metrics in the Model view, which can also be configured to set allowed limits. They do not run from command line for build integration afaik so I found them not very helpful.
I know the highly customizable Java (and .Net tools) like PMD, FindBugs and CheckStyle which generate XML or HTML statistic reports, and also integrate very well with build tools (Ant, Maven, Hudosn) - but for Delphi nothing comparable has crossed my road so far.
It seems those 2 are the most used. You can also try:
http://jedicodeformat.sourceforge.net/
The best one is Pascal Analyzer (PAL) by Peganza, which you said you tried and found unsuitable, but did not say why. I will say a bit in its favor: It's Commercial, inexpensive, and so worth it. They recently released version 5, and if version 5 doesn't do what you want, you should tell them what you want, because they have always answered my requests whenever I have mentioned a feature I wish the product would add.
We use it instead of the high-end SKUs of Delphi's metrics because it costs less and does more than the built-in $3000 stuff. I think it costs about $160 us.
I am a happy customer. Here is a sample of some of the metric areas that I like:
convention compliance - class names that don't start with T, exception types don't start with E, class fields not in private, identifiers with goofy names, class visibility confusion or bad order, local identifier/unit outer scope identifier clashes. Inconsistent case, Many many many more!
The weakness is that the output is plain text in a "TMemo" control. Of course, I have found a lot of ways to take that output and write my own small sort/filter utilities to mine even more useful stuff from the reports. A powerful tool that you won't be able to live without once you try it.
I realize you said in your answer that you tried that already, but if it's not what you want, it's already the best LINT like tool for Pascal that currently exists.
If you're into writing your own style checking, you can write a .exe in Delphi to look for bad things being committed. Call that in a pre-commit hook into your repository.
You can examine the differences of a checkin by using SVNLOOK.
ex:
excerpt from pre-commit.bat
SVNLOOK diff -t "%2" "%1" | MyCustomFilter.exe
IF %ERRORLEVEL% == 0 GOTO EOJ
EXIT 1
:EOJ
EXIT 0

What are the recent changes to F#?

I am starting to learn F#. I am well versed programming languages like C# (and using the .NET framework in general), but functional programming is new to me. The way I learn best is by taking a book about the subject and starting to read - so I grabbed a copy of "Expert F#" and "F# for scientists". A few times I got the impression that those books seems already to be outdated due to recent changes in the language - nothing too dramatic, but it gives a bit of a nagging feeling that there may be more.
Now that F# 2.0 seems to have stabilized, it would be nice to see how the 'real' F# has turned out compared to the versions of the language described in those (and similar) books.
So my questions are:
what topics have changed since the books were printed, and are no longer valid as described? Are ther any chapters I can skip completely? (I am aware that some functionality has been moved to the the PowerPack, though it is not totally clear to me which functionality is in the PowerPack, and which is in the standard install)
what features of the language are described correctly, but have newer alternatives available? (Is the description of events still up to date?)
which features of the language I should be aware of that were added (or modified) since those books were written?
are there other recent changes in the language that I should be aware of?
edit:
Thanks all for the answers!
As far as release notes go, I was able to dig up the following "detailed release notes" posts on Don Syme's blog, applying to versions of F# after 1.9.2 (the version "Expert F#" mentions as being the version used in the book):
Versions 1.9.3.7 and 1.9.3.14
Version 1.9.4 and 1.9.4.19
Version 1.9.6 (September 2008 CTP)
May 2009 CTP ("Beta 1")
October 2009 ("Beta 2")
2.0 RC (February 2010)
I didn't find anything about version 1.9.5 - did that one ever exist?
I probably can't give a complete answer, but here are some things that come to mind as having undergone non-trivial changes in the past two years I've been working on F#...
Minor changes:
Many library functions have been
renamed. There originally was a penchant for underscores that has
since been removed to be more
.Net-like. So e.g. Seq.to_array is
now Seq.toArray. Some significant changes to async and quotations APIs too.
#light is now the default, you can quit putting it at the top of every file
some changes to the APIs/declarations of events and enums (the language reference and library docs on MSDN are good for up-to-date information)
no more need for [<OverloadID>] to make overloaded member functions
New features:
Units of measure was new in Beta1.
comparison and equality constraints were new in Beta2.
unmanaged constraint in RC.
(check out the "release notes" for various releases, linked in prior bullets, for more)
I'm doing a windiff of the lastest(1.9.9.9) and previous(1.9.7.8) release of FSharp.
I noticed many added calls to checkNonNull in Array, Seq, Reflect and the Quotation module. I assume these calls were added to protect F# libs from being passed nulls from another language such as C#. Any insight Brian? The function nullArg throws an ArgumentNullException.
let inline checkNonNull argName arg =
match box arg with
| null -> nullArg argName
| _ -> ()
There is a new override ToString in set and improved formatting for set and map printing with sformat aka printf "%A".
Some internal cleanup of BigInteger for use with .net 4.0.
I see a lot of internal changes to async as Brian mentioned.
Some internal changes to Event to use IObserver.
I finished going through all the changed fs files and most of the changes are to private functions that are not exposed directly. The only thing that may effect the user is different pretty printing of sets and maps.
Check out the Release Notes.

Resources