Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Handling Exceptions

  1. #21
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,466
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    Quote Originally Posted by peter View Post
    Also I have been playing with a new routine, but I need to return a list of sublists ( as a result buffer).

    I have been playing around with Lists, Arrays, Structures, but nothing has the versatility of a LISP List.

    Suggestions or examples?

    I want to be able to manipulate one of the above data types in .net and convert it to a result buffer as a return value.

    I want each cell in the 2d array to contain any of the object types.
    I believe this is what you're after:

    Quote Originally Posted by Returning nested list from .NET to LISP, by Adam Nagy

    Returning nested list from .NET to LISP

    ...

    You can find the ResultBuffer TypedValue related codes in the LispDataType enum. As you can see RTRESBUF/5023 is not in the list. You could place the nested part in a LispDataType.ListBegin/LispDataType.ListEnd section instead:

    Code:
    [LispFunction("GetNestedList")]
    public static ResultBuffer GetNestedList(ResultBuffer resBufIn)
    {
      ResultBuffer resBufOut = new ResultBuffer();
     
      resBufOut.Add(
        new TypedValue((int)LispDataType.Text, "Main List Item 1"));
     
      resBufOut.Add(new TypedValue((int)LispDataType.ListBegin));
        resBufOut.Add(
          new TypedValue((int)LispDataType.Text, "Nested List Item 1"));
        resBufOut.Add(
          new TypedValue((int)LispDataType.Text, "Nested List Item 2"));
      resBufOut.Add(new TypedValue((int)LispDataType.ListEnd));
     
      resBufOut.Add(
        new TypedValue((int)LispDataType.Text, "Main List Item 2"));  
     
      return resBufOut;
    }
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  2. #22
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    1,029
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    What I was looking for is this


    '(("ID" "Name" "Number")(1 "First" 1.0)(2 "Second" 2.0)(3 "Third" 3.0))


    I know how to do this as a result buffer (similar to your example)
    but I am looking for a compatible .net object other than a result buffer to hold it.

    This is the list of sub-lists that I was referring to.

    Most all of my data handling functions (in lisp) accept or return this kind of list.

    Like (csvfiletolist strCSVFullName strDelimiter) would read a csv ascii text file and return a list of sub-lists parsed with the strDelimiter
    Last edited by BlackBox; 2014-02-21 at 09:36 PM. Reason: It is not code... It is a return value [BlackBox]: If you insist there's a difference.
    AutomateCAD

  3. #23
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,466
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    Oh okay... I only know of a couple of ways to do something like that; either use ResultBuffer (even if not being passed back to LISP), implement a custom FooCollection Type made up of one or more Foo Type, or use XML, etc.

    Not sure if that helps really, but it's the best I have at the end of this very long, but awesome week.

    Happy Friday!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  4. #24
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    1,029
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    I would be very interested in seeing a result buffer to XML function.

    Or coding one.
    AutomateCAD

  5. #25
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    Quote Originally Posted by peter View Post
    It is funny that the innuendo on the word 'weaker' implies less than.
    Sorry, that "weaker" is simply the official naming. Since the 60s there's been debates raging on which is better: weak/strong typing. The C-like languages (actualy a misnomer, it should rather be the Fortran-like languages: Ada/Basic/Pascal/C/C++/Java/C#/VB/etc.) tend to use strong typing (a few grey areas but only in special cases). If it's better depends on situation: if you need to type-check a lot, then having the compiler do it for you is obviously more efficient. If you want to mix types in a collection, then weak typing makes it a lot easier to work with.

    My view of this is weak leaves types up to the programmer to manage. Strong restricts the programmer into what types to use where. There can be good and bad points on both sides.

    Quote Originally Posted by peter View Post
    I have been playing around with Lists, Arrays, Structures, but nothing has the versatility of a LISP List.
    That's exactly true. One of the difficult portions to accomplish using C#/VB.Net. The only true way to get around this is to use object inheritance in a strong typed language. If you want the closest matching structure to a Lisp-list from the default DotNet libs, then you might use something like:
    Code:
    System.Collections.Generic.LinkedList<object>
    But then due to the strong typing you have to check what actual type each of those items are and then type-cast accordingly. This is where strong typing makes the programmer's life difficult.

    Lately the var type's been added to C#, but restricted to only be usable inside a method as a local variable - you can't use it as a type for a datastructure.

    If you really want to use a Lisp-like list, then you could use IronScheme's implementation of the Cons type: https://github.com/leppie/IronScheme...untime/Cons.cs But IMO it's not too much different to use than a LinkedList of objects, in fact it IS a linked list of objects, just implemented using CAR/CDR.

    Even IronPython uses strong typing too (as does IronRuby), though they use dynamic typing (a sub-set of weak typing, unlike C#/VB/F#, but a lot like Lisp does) - i.e. a variable can contain anything, but it doesn't adjust to accommodate the use of a specific type inherently. I.e. the language itself doesn't add implied type casts for everything like Pearl/PHP/JavaScript does. Even Lisp is not fully weakly typed, e.g. you can't add a string containing numerals to an int and expect a result containing either a concatenated string or an int containing a total. That's actually why weak typing isn't fully implemented (in most cases) - there are usually ambiguity when 2 different types are combined, so either the language makes a call on which will always be used (like Pearl/PHP/JS does) or the language disallows such and makes the programmer specifically cast/parse to accommodate (like Lisp/Python/Ruby does). E.g. say you wanted to rather just append the integer's digits to the end of a string in Pearl instead of using its default of converting the string to an int and summing the 2 then returning a new int ... how would you do that?

    In C# you can make an implied casting operator between an object and a list of objects (similar to the example I showed before between doubles and strings). You'd probably do one to an IEnumerable/ICollection type though after checking if the object actually contains such - else "throw an exception" (which is exactly what Lisp does, try to run nth on an atom value and see what happens).
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  6. #26
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    Quote Originally Posted by peter View Post
    I would be very interested in seeing a result buffer to XML function.

    Or coding one.
    IMO XML is nothing but a convoluted and restricted version of a Symbolic Expression.

    http://c2.com/cgi/wiki?XmlIsaPoorCopyOfEssExpressions
    http://rwmj.wordpress.com/2009/10/30...s-expressions/

    So you could say XML is the strong typed version of S-Expr. What I'd actually like to see is something like that Lisp-list being Serializable - then making a XML from that would be a very simple task, as would reconstructing the list from the XML.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  7. #27
    Woo! Hoo! my 1st post
    Join Date
    2019-07
    Posts
    1
    Login to Give a bone
    0

    Default Re: Handling Exceptions

    Excellent thread! Thank you!

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Better handling of bid packages
    By IanR in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2010-03-12, 05:56 AM
  2. Error Handling
    By ticad02 in forum AutoLISP
    Replies: 16
    Last Post: 2009-12-21, 03:39 PM
  3. Handling Revisions
    By dbaldacchino in forum Revit Architecture - Tips & Tricks
    Replies: 3
    Last Post: 2006-12-15, 03:23 AM
  4. Handling Addendums
    By jmessner in forum Revit Architecture - General
    Replies: 8
    Last Post: 2006-10-11, 02:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •