Basic Erlang module troubles - erlang

So I straight up copy and pasted the code from the Erlang docs: https://erlang.org/doc/reference_manual/modules.html#module-syntax
Please help!

The module didn't compiled. To fix it try this in the Erlang shell (eshell):
1> c(m).
ok
2> m:fact(1).
1
See documentation on how code loading works.

exception error: undefined shell command
almost always means that the shell environment does not have the intended function, which can also mean that the module which contains its definition has not been loaded for all the code that we write by our hand and execute. You can deliberately try to misspell some auto loaded BIF(s) for example "length1" and you will still see same message showing up.

Related

Source env variables from bitbake-made sdk using Fish

When you compile a SDK using bitbake and have to source like :
source /opt/poky/.../environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
It can't be accomplished through fish, which is expected as the export sintaxe is different (i.e. set -x ...). I tried even to add #!/bin/bash on the first line, which also doesn't work. Does anyone knows a good way for it?
Workaround: Nowadays I run a bash inside the fish prompt to be able to compile binaries, which is not the best way but works. Don't let those small things push oyu away from fish :)
#charego mentioned some good ideas, thanks! :)
Fish-bax
So you can run it as:
bax 'source /opt/poky/.../environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi'
The only down side is that the auto completion does not work inside quotes, so one will need to write the whole path to the file. Although it's still better to have a fish running on top of a bash.
Bass
Bass did not worked, as it crashs with: Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'
Foreign-env
Foreign-env also didn't work. It's possible to to set the variable, although it threw warning:
warning: include location "/usr/local/include" is unsafe for cross-compilation [-Wpoison-system-directories]
and it does not compiles, probably it misses a few variables to export.
TL;DR Go with Fish-bax, at least it works :)

Mainframe CEE3DD abend - CEE3501S - Module not found in COBOL Dynamic Call

I have encountered an issue recently while processing a CICS transaction. My CICS transaction is calling a chain of dynamically linked COBOL modules. The transaction runs fine for the first time after the PGM-A load is new copied into the region. When I try to process the transaction for the second time, I keep getting CEE3DD abend saying the module not found for PGM-B which is being called from PGM-A. IF I do a new copy for PGM-A in CICS, the transaction again runs fine.
Something is wrong with the CICS setup or memory but I am not able to figure it out. PGM-A is working fine in batch processing. PGM-B has no issues when it is called from any other PGMs except PGM-A.
Can someone share some thoughts on what may be wrong with this?
To invoke your program via CICS, it must be compiled with the NODYNAM option.
It admittedly seems counter-intuitive, but using the DYNAM option will cause CICS stubs to be loaded, instead of your intended programs, and result in the CEE3501S condition.
So, compile your programs with the NODYNAM option to avoid this error condition.
See the following links for additional info:
https://www.ibm.com/support/knowledgecenter/en/SSGMCP_5.3.0/com.ibm.cics.ts.applicationprogramming.doc/topics/dfhp3_cobol_subprog_rules.html
http://www-01.ibm.com/support/docview.wss?uid=swg21054079
Does PGM-A use "CALL VARIABLE" to invoke PGM-B? If so check the contents of VARIABLE on the second run (the contents of that variable will probably be reported in the error message. The contents of the variable may be overwritten by a bug in PGM-A. That might explain why the program always fails after the (seemingly) succesful run and after a newcopy.
Converting this from dynamic to static worked. But the question remains why it was not working with dynamic linking.

Closure compiler does not write out errors

I have a Groovy script that runs the closure compiler latest version.
def command = "java -jar $compiler --js $orderedDependencies --js_output_file $minFilename --create_source_map $mapFilename --compilation_level WHITESPACE_ONLY --source_map_format=V3 --language_in=ECMASCRIPT5 --debug --formatting=PRETTY_PRINT"
command.execute(null as List, outputDir).waitForProcessOutput(System.out, System.err)
When I use it without the --language_in option, I get error output. When I add the command option, I don't get any error output, but it breaks somewhere, because nothing gets created and the web interface is broken.
Does anyone have any idea why this might be?
I'm not sure what the problem is since the code you provided isn't enough the reproduce it.
But chances are that you are searching in the wrong place: the .execute() command can be quite annoying. Take a look at this question to get some ideas on what could go wrong and how to solve it: Trying to send an email trough a groovy shell script

Loading lua script files in redis

Could someone give an example of how to load and execute .lua script files in windows. I am using ServiceStack redis to loadluascript. It works to certain scripts which don't have module(...) like things.
I am getting this error
Error compiling script (new function): user_script:5: cannot use '...' outside a
vararg function near '...' , sPort: 61688, LastCommand:
Any help by giving an example would be highly appreciated.
Thanks in advance
It would help if you posted the Lua script you are trying to load or execute.
Three dots don't have anything to do with modules:
Vararg expressions, denoted by three dots ('...'), can only be used
when directly inside a vararg function
I guess this answers your question: your Lua code is simply invalid.
Speaking of modules: you can't load your own modules in Redis Lua, which you might already know. See http://redis.io Scripting.
The solution for the above kind Lua script is to prepend local before a function or all variables. I took out the module thing and tweaked the Lua script to make it work. Later I realized the script will not be any use to me :). Thanks for looking into this post.

In Erlang how can I compile a module from within a module?

I have tried :
c(module_name).
: but this only works from the shell, and gives an error when I try to run it from within a module.
If you want exactly that behaviour, c:c(module_name) will call the same function called by the shell. I would hesitate to put code that calls user_default (c) functions in production code, so you might want to look at the source for the function and replicate it in your own code so you don't get bitten by a behaviour change in a future erlang release.
You might want to have a look to the compile module and to the compile:file/2 function in specific.

Resources