mnemosyne:string_to_handle() unpleasantness

stephen.wight@REDACTED stephen.wight@REDACTED
Wed Sep 20 20:30:50 CEST 2000


I would like to compose a list comprehension query in a non-Erlang
environment and pass the query clause as a string to mnemosyne.

I'm unable to use the "undocumented" string_to_handle() function
without getting an error from erl_parse:normalize(), which is reported
by mnemosyne:setup_query().

I'm testing this with a trivial LC query embedded in a function -
note my two alternative query construction methods for debugging;
this is to verify that the same LC compiles and runs correctly
when used 'normally':

evalq() ->
    Q = mnemosyne:string_to_handle("query [X || X <- table(atable)] end."),
    %% Q = query [X || X <- table(atable)] end,
   
    case mnesia:transaction(fun() -> mnemosyne:eval(Q) end) of
	{aborted, Err} ->
	    io:format("transaction aborted ~n", []),
	    Err;
	{atomic, QueryResult} ->
	    io:format("query result ~n", []),
	    QueryResult;
	_ ->
	    false
    end.


The error object being returned looks like this:

21> mntools:evalq().
transaction aborted 
{function_clause,[{mnemosyne,setup_query,
             [{'EXIT',{function_clause,
                          [{erl_parse,
                               normalise,
                               [{call,
                                    0,
                                    {atom,0,'MNEMOSYNE RULE'},
                                    [{tuple,0,[{...}|...]}]}]},
                           {erl_parse,normalise_list,1},
                           {erl_parse,normalise,1},
                           {erl_parse,normalise_list,1},
                           {erl_parse,normalise,1},
                           {mnemosyne_lc,
                               '-one_lc_to_handle/1-fun-1-',
                               2},
                           {lists,foldl,3},
                           {mnemosyne_lc,one_lc_to_handle,1}|
                           more]}}]},
  {mnemosyne,cursor,2},
  {mnemosyne,eval,1},
  {mnesia_tm,apply_fun,2},
  {mnesia_tm,execute_transaction,4},
  {mntools,evalq,0},
  {erl_eval,expr,3},
  {erl_eval,exprs,4}|
  more]}


Thanks for any help or suggestions for an alternative route to
get this done!!

-steve wight








More information about the erlang-questions mailing list