C++ cling - any function like python's dir on the repl? - clang

Is there a way to list an objects properties and methods like python's dir?
https://docs.python.org/2/library/functions.html#dir

.g would do something similar. Use .help for more information at the cling command prompt.

Related

ocaml: Is there an environment variable to set the search path for #use and #load?

I've been wondering, if there is an environment variable to set the search path for #use and #load for the ocaml toplevel.
What I think I know so far:
I can use findlib instead of "raw" #use and #load. findlib looks at some environment variables for the search path.
I can set a search path with -I.
Experiments seem to indicate that CAML_LD_LIBRARY_PATH does not influence #use (script loading) and #load (byte code file loading).
(updated) I can use #directory to add the desired path - but unfortunately this only takes a string literal, so i can't pass something I read from the environment at run time. (Update: I forgot to mention #directory originally and why it doesn't fit my use case).
What I want to do:
Run ocaml programs as scripts
Point ocaml to script libraries and script fragments with an environment variable
Avoid, in some scenarios, to create a full findlib library.
Presently I'm not using ocaml as interpreter, but a wrapper that adds a path to the invocation. I want to avoid the wrapper.
(I hope the questions makes sense now, after you know my use case)
So: Is there an environment variable to set the search path for #use and #load without resorting to a wrapper?
More Details
What I'm currently doing:
#!/usr/bin/env oscript2
#use "MyScript"
#load "SomeModule.cmo"
(* ... more ocaml *)
oscript2 is a wrapper around ocaml that basically sets the search paths for #use and #load, but finally executes the toplevel ocaml withe something like
exec ocaml -I .... ...some-byte-code-modules... "$#"
MyScript and SomeModule.cmo live outside of the "normal" Ocaml search path. The actual location might change, but after login (and working through the profie scripts) there is an environment variable (today it's OSCRIPTLOAD_PATH) that tells me, where alle loadable byte code and ocaml script files might live.
This works well, a variant of that setup has been in use for years (at least 7).
The one thing that bothers me there, is: The wrapper, the simple fact of it's presence, looks homebrew, so I'd like to avoid it, to make a better impression on potential future users of the script collection. What I'd like to do
#!/usr/bin/env ocaml
#use "MyScript"
#load "SomeModule.cmo"
(* ... more ocaml *)
and have ocaml itself pick up the search path from some environment variable (I'm free to change the variable name, that is under my control, but I don't want to install script and byte code libs into the default search path, and, as already stated, I' asking if I can do that without findlib).
Basically (as already stated at the very beginning) I'm looking for an environment variable that controls the search path for #use and #load. I'm not looking for toplevel directives and not for wrappers that retrofit this feature. (Thanks everyone for those suggestions, but unfortunately I've already gone that road, it's feasible, but here I'm looking for an alternative purely for cosmetic reasons).
Recent research didn't bring up that such a variable exists, but I thought I'd be asking here, before giving up on it.
From inside the OCaml toplevel you can use the #directory "foo";; primitive to add an include directory.
Here's a shell script that runs the OCaml toplevel while adding a directory to the search path taken from an environment variable named EXTRA_OCAML_DIR.
#!/bin/sh
ocaml -I "$EXTRA_OCAML_DIR" "$#"
If you run this instead of ocaml, you will have a directory in the load path specified by an environment variable.
It seems a little obvious, but maybe it will spark an idea that is more helpful.

Determine module file location

after loading a module in Lua, I'd like to determine what module file this corresponds to. In python, you do this with code like:
import module_name
module_name.__file__
So in Lua if I do something like
require 'math'
what do I put next to determine where this module is located? Btw, I don't actually need the location of math, but instead have some other third-party packages that were downloaded and want to know what copy of the build files are actually being used when I invoke Lua.
The package library might give you what you need.
For instance, if I have util.lua in my Lua path such that I can write:
require 'util'
I can get the path to the file like this:
print(package.searchpath('util', package.path))

Where can i find an msi conditions parser

I am looking for a library or utility that can parse the msi launch conditions. Basically i want to take these statements and translate them into our own langauge, but before i do that i need to parse it up.
I can already pull a list conditions out of an MSI, for example:
NOT VersionNT OR (VersionNT = 501 AND ServicePackLevel >= 2) OR (VersionNT > 501)
But i was hoping there was already something that can break this up into a more interpretable format.
Additional question, what is this language called? I can figure out how to refer to it or search for it.
Cheers
See:
Conditional Statement Syntax
Windows Installer exposes a Win32 function and an Automation Method for evaluating conditions.
MsiEvaluateCondition Function
Session.EvaluateCondition Method
Try the Wine source code. They have the following grammar file for conditions:
http://source.winehq.org/source/dlls/msi/cond.y

Erlang: using include from the console?

The include directive is usually used for a .hrl file at the top of an .erl file.
But, I would like to use include from the Erlang console directly.
I am trying to use some functions in a module. I have compiled the erl file from the console. But, the functions I want to use do not work without access to the hrl file.
Any suggestions?
"But, the functions I want to use do not work without access to the hrl file."
This can't be true, but from this I'll take a shot at guessing that you want access to records in the hrl file that you don't (normally) have in the shell.
If you do rr(MODULE) you will load all records defined in MODULE(including those defined in an include file included by MODULE).
Then you can do everything you need to from the shell.
(Another thing you may possibly want for testing is to add the line -compile(export_all) to your erl file. Ugly, but good sometimes for testing.)
Have you tried the compile:file option? You can pass a list of modules to be included thus:
compile:file("myfile.erl", [{i, "/path/1/"}, {i, "/path/2/"}])
It's worth nothing that jsonerl.hrl doesn't contain any functions. It contains macros. As far as I know, macros are a compile-time-only construct in Erlang.
The easiest way to make them available would be to create a .erl file yourself that actually declares functions that are implemented in terms of the macro. Maybe something like this:
-module(jsonerl_helpers).
-include("jsonerl.hrl").
record_to_struct_f(RecordName, Record) ->
?record_to_struct(RecordName, Record).
... which, after you compile, you could call as:
jsonerl_helpers:record_to_struct_f(RecordName, Record)
I don't know why the author chose to implement those as macros; it seems odd, but I'm sure he had his reasons.

Komodo Edit: How to do some of these basic Macro and Snippet operations?

I am wondering how to do (or where to find documentation) on these basic
macro and snippet operations in Komodo Edit.
1) FILE/IO: write a string to a temporary file from within a komodo javascript macro
2) FILE/IO: read the content of a text file into a string within a komodo javascript macro
3) INCLUDES: cross-reference local javascript "include" libraries within a macro,
or something equivalent to #script src="~/mylocal_javascript_addons.js" So I can consolidate macro code.
4) SNIPPET_OUTPUT: create a snippet interpolation placeholder that returns the output of a
user-defined javascript function or macro.
For example:
[[%(myscript:SayHelloWorld())]]
[[%(foomacro-MyAgeInMilliseconds)]]
5) MACRO_OUTPUT: macro that takes a multiple-line selection in the current buffer and passes
it to a local script or batch file, and then replaces the selection with the output
result. (Need a way to do this in MSFT Windows, not just linux).
If you can answer one or more of these using Python instead of Javascript, that's great, but please include sample code or a link to it, because the Python documentation seems to be extremely TODO.
Don't have your answers, but you might have more luck asking here:
http://community.activestate.com/forums/komodo-extensions

Resources