Shop OBEX P1 Docs P2 Docs Learn Events
User Spin Library / Search Path — Parallax Forums

User Spin Library / Search Path

hippyhippy Posts: 1,981
edited 2007-10-24 19:58 in Propeller 1
Is there anyway to specify a directory of Spin files which can contain objects to be automatically included when required beyond keeping them in the working directory or the Propeller Tool Library directory ?

I'm working on two separate projects which use a common object which itself is being worked on separately and I don't want to put it it in the Propeller Tool Library.

The string after the object's identifier is a filename ( the error message for putting \ in says so ) but there seems to be no way to specify a directory path in that string.

Have I missed a trick or is it something lacking in the Propeller Tool ?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-24 01:31
    I don't think you've missed anything. As I understand it, the Propeller Tool searches first in the working directory, then in the Propeller Tool Library directory. That's it!
  • scottascotta Posts: 168
    edited 2007-10-24 12:42
    We need #Include !

    Scott
  • hippyhippy Posts: 1,981
    edited 2007-10-24 13:45
    I've found developing with included multi-use objects to be quite a challenge.

    I have a video driver object which includes quite advanced number formatting code and a PUB Demo routine so the object can be run standalone for testing / proving or included as a sub-object. I then create another video driver object, exactly the same again.

    Then I create a higher level object which can select one of the two video drivers at run time and switch between them. Easy, but if I want to minimise code used ( consolidating the duplicated formatting routines in each video driver ) I have to move those routines up to the new parent object.

    Again, easy enough to do but then it breaks the standalone nature of the video objects and any other application which relied on the video object having the formatting code in it.

    Either that means having two very similar video driver objects or an intermediate object has to be created to use that video driver which provides the removed routines. That of course is very similar to the parent object for the two driver version but not quite.

    No matter which way one goes one soon ends up with multiple objects which differ only slightly so bug fixing and enhancement means a whole set of object files all need updating and it's easy to miss one.

    If one doesn't care about wasted memory and duplicated routines then it's no problem; simply include all formatting routines in every object, but that then carries the cost of editing every single object should those routines ever need altering.

    Ideally an intermediate level object should work as an abstraction layer for top-level objects regardless of what's below, but that's not so simple because an intermediate object can only use objects it names and not all top-level objects need all bottom level objects so there needs to be a third level which directs the abstraction layer down to the bottom end video driver objects.

    As long as one designs for two intermediate levels between top-level objects and the lowest level driver objects it's fine, but even then there is still unused code taking up space in the abstraction layer.

    What's really needed is #if or, even better still, unused and dead code removal by the compiler.
  • LeonLeon Posts: 7,620
    edited 2007-10-24 17:47
    A macro-processor like m4 could be used for include files, conditionals, etc.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-24 17:55
    @hippy: Many problems of your kind can be solved by mercyless modularisation! Just make an object for anything you want and reference it from OBJ.
    The only rule to be complied to is: USE NO VARs

    In fact there is no need to use VARs at all (only if you WANT to have OBJECT members)

    There is a trade-off when you need WORD or BYTE space and want to have the simple compiler support of autorecognizing these identifiers and using correct stride... This is more awkward with local variables or DAT variables to be used as BYTEs or WORDs

    Post Edited (deSilva) : 10/24/2007 6:03:58 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-24 18:57
    hippy,
    Have a look at the code for the I/O drivers in the Propeller OS (see Graham Stabler's sticky useful links list). The various I/O drivers allocate their work areas in the high end of RAM and do all their references via pointers in specific locations at the top of RAM. The drivers are split into an initialization and assembly portion and an API portion and the API portion has no VARs and can be referenced at multiple levels in the object structure. The downside of this is that there are interpretive code space optimizations for local variable and VAR section references that you can't take advantage of. Careful use of local variables can sometimes help there.
  • Mark BramwellMark Bramwell Posts: 56
    edited 2007-10-24 19:36
    I like to cast my vote for #include and conditional defines #define as well as #if

    It could be as simple as a new version of the Spin Editor since those enhancements do not change the spin language.

    One area that the conditional defines would be handy is in the video config. We have multiple boards out there with people trying to change the configs for the video settings. A common config section with #ifdef propRPM #ifdef proto #ifdef hydra would make life easier for everyone.
  • hippyhippy Posts: 1,981
    edited 2007-10-24 19:58
    @ deSilva, Mike : Thanks for the tips. I'll look into those ideas but it's a lot of messing about and jumping through hoops when a simple #if would solve most of the problems. Equally a proper callback mechanism up to a parent object would help a lot.

    @ Mark : I agree entirely. It can be done with constants set true or false but that wastes a lot of memory and the constants have to be passed down the object chanin.
Sign In or Register to comment.