Author Topic: VB.NET Evaluation of a VB.net Expression  (Read 23460 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VB.NET Evaluation of a VB.net Expression
« Reply #15 on: May 31, 2010, 12:19:55 PM »
I don't have an example, but theoretically it should be possible. Presuming the wrapper is a predefined function that merely holds the code.

If you always use the same wrapper name you can always unload that wrapper function could you not?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Peter Jamtgaard

  • Guest
Re: VB.NET Evaluation of a VB.net Expression
« Reply #16 on: May 31, 2010, 04:14:47 PM »
Keith,

I have been playing with an alternate to the netload command line command.

I am interested in capturing the wrapper, as I mentioned.

Is this a good place to start or should I use that something similar to the
code shown on eggheadcafe referenced above?

Peter

Code: [Select]
<LispFunction("Netload")> _
    Public Function Netload(ByVal rbfNetAssemblyFile As ResultBuffer) As ResultBuffer
        Dim rbfReturn As New ResultBuffer
        Try           
            Dim arrNetAssemblyFile As TypedValue() = rbfNetAssemblyFile.AsArray()
            System.Reflection.Assembly.LoadFrom(arrNetAssemblyFile(0).Value.ToString)
            return Nothing
        Catch
            rbfReturn.Add(New TypedValue(&H138D, "Catch Error"))
            Return rbfReturn
        End Try
    End Function

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VB.NET Evaluation of a VB.net Expression
« Reply #17 on: May 31, 2010, 06:42:44 PM »
After revisiting the code at eggheadcafe, you will note that is writes the class on the fly and then compiles it and executes the function EvalCode The wrapper itself would necessarily have to be the evaluator. You could netload the evaluator and send it the string to evaluate, but it won't help you in the IDE. Presumably you want to execute .Net functions in lisp (as evidenced by your function above).

Why build your function around the code provided, netload it, and pass to it the string needed to be evaluated. Presumably the arbitrary class would be self depreciating when the class is disposed, thus unloading it wouldn't be necessary. It would require some testing to be sure, but based on what I've seen, it could be really cool to introduce some .net functionality to lisp.

When I get time, I think I will look into this a bit more.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: VB.NET Evaluation of a VB.net Expression
« Reply #18 on: May 31, 2010, 11:16:05 PM »
@ Peter

you should test arguments to see if they are null
you should return true on success and nil on error. the way you have it now, you're returning nil on success and a list on failure.

IMO, When interacting with lisp, you should try you make your functions behave as a lisp function would

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: VB.NET Evaluation of a VB.net Expression
« Reply #19 on: May 31, 2010, 11:38:02 PM »
something like this


Code: [Select]
    // going to return nil or 1, I think one of the
    // cad versions had a bug with with T
    [LispFunction("LOADNET")]
    public static object LoadNetModule(ResultBuffer args)
    {
      try
      {
        if(args == null )  return null;
        TypedValue[] tvs = args.AsArray();
        if (tvs.Length == 0)  return null;
        TypedValue arg = tvs[0];
        if (arg.TypeCode != (int)LispDataType.Text) return null;
        string file = arg.Value as string;
        if (string.IsNullOrEmpty(file)) return null;
        System.Reflection.Assembly.LoadFrom(file);
        return 1;
      }
      catch
      {
        return null;
      }
    }

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: VB.NET Evaluation of a VB.net Expression
« Reply #20 on: June 01, 2010, 04:36:13 AM »

ok, I'll play ...
How do you load that after it's compiled into an assembly ??
 
;-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: VB.NET Evaluation of a VB.net Expression
« Reply #21 on: June 01, 2010, 05:13:35 AM »

ok, I'll play ...
How do you load that after it's compiled into an assembly ??
 
;-)

Sorry, I should have posted in this thread
http://www.theswamp.org/index.php?topic=33538.0

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: VB.NET Evaluation of a VB.net Expression
« Reply #22 on: June 01, 2010, 05:18:43 AM »

ok, I'll play ...
How do you load that after it's compiled into an assembly ??
 
;-)

Sorry, I should have posted in this thread
http://www.theswamp.org/index.php?topic=33538.0


OK, no hassles ..

but somewhere you'd still need a NETLOAD, yes ??
.. and I don't see a problem with using netload, but perhaps I've missed some part of the discussion.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: VB.NET Evaluation of a VB.net Expression
« Reply #23 on: June 01, 2010, 05:24:08 AM »

ok, I'll play ...
How do you load that after it's compiled into an assembly ??
 
;-)

Sorry, I should have posted in this thread
http://www.theswamp.org/index.php?topic=33538.0
.... I've missed some part of the discussion....

I think that was me, I'll go back an play in my ARX sinkhole  :laugh:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: VB.NET Evaluation of a VB.net Expression
« Reply #24 on: June 01, 2010, 05:28:07 AM »
oh yeah, that's right ... take your ball and run away and play with Paul  :-D
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: VB.NET Evaluation of a VB.net Expression
« Reply #25 on: June 01, 2010, 06:29:31 AM »

footnote:
If [you] paid attention to the API wishlist @  http://through-the-interface.typepad.com/through_the_interface/2010/05/theres-still-time-to-fill-out-the-2010-api-wishlist-surveys.html
you'll notice that C# scripting (as well as an enhanced VLIDE) is scoring high on the voting.
... though we'll need to wait to see what action is taken regarding the items on the list.


further footnote :
Peter, how'd you go with your submission for a course at AU this year ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

sinc

  • Guest
Re: VB.NET Evaluation of a VB.net Expression
« Reply #26 on: June 01, 2010, 08:22:00 AM »
It would require some testing to be sure, but based on what I've seen, it could be really cool to introduce some .net functionality to lisp.

How funny.  I wouldn't use the word "cool" to describe Lisp.Net...  Maybe "cringe-worthy"...  Or maybe just "ugh"...   :-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VB.NET Evaluation of a VB.net Expression
« Reply #27 on: June 01, 2010, 08:24:38 AM »
I suppose its a good thing that you don't make all the rules ... or that any one person doesn't .. it would be a pretty dull place to live
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: VB.NET Evaluation of a VB.net Expression
« Reply #28 on: June 01, 2010, 08:37:52 AM »
I think  L# would have been really cool especially with .NET4, too bad it's not being maintained.

sinc

  • Guest
Re: VB.NET Evaluation of a VB.net Expression
« Reply #29 on: June 01, 2010, 11:33:35 AM »
I suppose its a good thing that you don't make all the rules ... or that any one person doesn't .. it would be a pretty dull place to live

Sometimes I really wonder about the posts I read here...  Some of them get pretty far out there.