Talk:Executable library: Difference between revisions

 
(13 intermediate revisions by 4 users not shown)
Line 1:
==History==
This task came from discussions [[Talk:Scripted Main|Here]]. I was nervous about just deleting all the code for that task so decided to create this, mark the other for maybe future deletion, and see how things go. --[[User:Paddy3118|Paddy3118]] 23:44, 14 March 2011 (UTC)
 
==We should merge Executable library's content back into Scripted main==
Executable library is perhaps a better name, but the examples on it overshadow the point of having an executable library. Leave hailstones to another article and just show people how to do Python's if __name__=="__main__": main() in multiple languages (the point of Rosetta Stone).
 
If you're having trouble understanding the point of Scripted main / Executable library, run these Perl programs (https://github.com/mcandre/scriptedmain/tree/master/perl) and look at their code. test.pl illustrates loading code from another Perl file. scriptedmain.pm doubles as both a library that can export code, and a self-contained executable in its own right.
 
Another example is ios7crypt (https://github.com/mcandre/ios7crypt), a command line tool for encrypting and decrypting Cisco router passwords. You can either call <lang sh> $ ./ios7crypt.scm -e monkey</lang> as a self-contained shell script, or <lang chicken>(load "ios7crypt")</lang> and treat the file like a library, accessing its methods like a normal API.
 
--[[User:Mcandre]]
 
:Or not! Hi Mcandre. If there has been no other improvements to scripted mains task description then I don't see a case for the two tasks to merge. The reasons for this task appearing will still exist. This task is about what pythons thing can give you rather than the thing itself and has already given us that excellent [[Executable_library#C|C example]] (IMHO). If you maybe extract the essence of your examples and put that in the scripted main task description then we could end up with two great tasks with slightly differing emphasis? --[[User:Paddy3118|Paddy3118]] 07:13, 13 September 2012 (UTC)
 
:: Executable library is duplicating the content of [[Scripted main]], thus both should be merged. The difference is that [[Scripted main]] contains bite size, simple examples in dozens of languages, while [[Executable library]] contains fewer, more overblown examples. I admit that my examples may be too simplistic to demonstrate the need for an "executable library", but I believe hailstone sequences are sufficiently complex that they distract from the purpose of an "executable library". --[[User:Mcandre]]
 
:::You say it is a duplicate then describe the differences. What you are ignoring is that the differences are important. An executable library could as a library contain code to work with the CGI protocol and when executed work as a CGI capable web server. Given that kind of existing capability a choice of adding extra functionality to an existing RC task alleviates some of the issues of how to have a meaningful task, that is not too complex.
:::In contrast, I have just reread scripted main and the description doesn't say that anything need be done to fulfil it! Someone needs to state in the task description just what is required to fulfil the task. You state that it has more examples. It also has issues in its talk page that are a long way from being resolved. --[[User:Paddy3118|Paddy3118]] 21:25, 13 September 2012 (UTC)
 
Scripted main states at the moment:
:''It is useful to be able to execute a main() function only when a program is run directly. This is a central feature in programming scripts; the feature can be called scripted main or modulino. Examples from GitHub. Sometimes getting the ScriptName is required in order to determine when to run main(). ''
You could try answering in the text:
* Run directly vs what? Explain what you mean by direct/indirect running.
* Is it central as stated?
* Tell the example writer what is required to complete the task. A task needs to tell you how to complete it, you know, "Bring me The Ark of the Covenant" rather than "There's this box and it has great power". Only one is a task (even if you do receive lots of boxes in the post for the other)
--[[User:Paddy3118|Paddy3118]] 21:25, 13 September 2012 (UTC)
 
==Tcl problem==
Line 61 ⟶ 85:
==Pike problem==
''"to use the library as a class, save it as HailStone.pike to use it as a module, save it as Hailstone.pmod "'' is not what the task is after. Make it one file and your on! --[[User:Paddy3118|Paddy3118]] 07:34, 7 November 2011 (UTC)
: the first file IS the one file you are looking for. it is the complete library, usable as an executable. the other two files demonstrateare howto satisfy the second requirement to build a second executable to use itthe library. since usage as a class orand libraryas a module are different, this solution provides both. i have added that to the explanations. thank you for pointing out that this was not clear.
: to elaborate:
:: every source file in Pike with any extension can be used as an executable if it has a <code>main()</code> function.
:: every source file can be used as a module if it has a <code>.pmod</code> extension.
:: every source file can always be used as a class (because it is one)
:: the code for all 3 forms may be identical.--[[User:EMBee|eMBee]] 08:24, 7 November 2011 (UTC)
 
:to use a class or module obviously only makes sense when called from another file and thus the extra files in the solution.--[[User:EMBee|eMBee]] 08:08, 7 November 2011 (UTC)
:::Hi eMBee, Are you saying then that the correctly formulated file with a .pmod extension can be used ''both'' as a module and as an executable (without name change)? If so, then all is well. --[[User:Paddy3118|Paddy3118]] 08:40, 7 November 2011 (UTC)
:::: yes, without name change. when used as an executable the extension is ignored. it only matters to separate class and module use.
:::: the .pike extension is only needed to let pike detect the class automatically, otherwise, since classes can be compiled at runtime, i can compile any file as a class manually using <code>program Hailstone_class = compile_file("hailstone.pmod");</code>.--[[User:EMBee|eMBee]] 08:55, 7 November 2011 (UTC)
:::::Ta! --[[User:Paddy3118|Paddy3118]] 09:40, 7 November 2011 (UTC)
 
==ADA and use of library==
It is not clear if the executable ./hailstone_test calls the compiled library ./hailstone or if it just compiles in the source to ./hailstone (which would not satisfy the task). --[[User:Paddy3118|Paddy3118]] 18:10, 29 May 2012 (UTC)
: With the proper set of compiler options, you can compile and link ''hailstone_test.adb'' and generate the executable hailstone_test '''without''' the source ''hailstone.adb'', but with the specification ''hailstone.ads''. Which seems to satisfy the task. On the other hand, as for most compiled languages, there is something in between source code and executable. To generate either of the the executables ''hailstone'' and ''hailstone_test'' the linker must access the object code in ''hailstone.o''.
 
::Hi, the task would require ./hailstone to be an executable and ./hailstone_test to be another executable that does not contain the code of ./hailstone but would get theat functionality from the ./hailstone file (probably by dynamic linking). That is very hard to do in a compiled language but not impossible - [[Executable_library#C|the C example]] shows that it can be done.
 
::As it stands, it seems as if the ADA code doesn't do enough. --[[User:Paddy3118|Paddy3118]] 20:14, 30 May 2012 (UTC)
Anonymous user