Menu

#545 Asset Directive

5.0.0
closed
None
none
1
2023-01-01
2013-05-16
Jon Wolfers
No

Following on from Frank Clarke's presentation to the 2013 Symposium, I wonder if users would benefit from an ::Asset directive. It would function much as the ::Constant directive, but the value would be whatever was on the subsequent source lines up to the next directive or end of file. The parser would treat these lines as comment.

This could be used for panel data as per Frank's presentation, or sql queries or user instructions or a host of other things

made up example

::class queries
::Asset Margin
Select profit - costs as margin
from balancesheet
::Asset liability
select cost
from balancesheet
where profit > 0

The string value of the asset could be retrieved by .class~AssetName ie .queries~Margin

An added bonus would be the ability to substitute values on retrieval, but perhaps that would over-complicate matters.

::class queries2
::asset sales %startdate %enddate
select sum(amount)
from sales
where invoicedate >= '%startdate'
and invoicedate <= '%enddate'

the substitution argument(s) can be any string and the passed parameters are substituted for it wherever it appears in the asset at retrieval time

qry = .queries2~sales('2012-01-01','2012-03-31')

would return the string
select sum(amount)
from sales
where invoicedate >= '2012-01-01'
and invoicedate <= '2012-03-31'

What do you think?

thanks Jon

Related

Feature Requests: #545

Discussion

  • Gil Barmwater

    Gil Barmwater - 2013-05-16

    My preferences: 1)standalone, not class specific, 2)subkeywords rather than %var_name, and 3)space delimited vs. comma delimited.

    Questions re. implementation: does the data that follows the directive include the NL characters or is it a single blank-delimited string of words? How would the proposed 'binary' data be included?

     
  • Jon Wolfers

    Jon Wolfers - 2013-05-17

    Hi Gil,

    I believe if it was implemented like ::constant then the user could decide whether it was class specific or floating

    I'm not sure how subkeywords would work. Can you give an example?
    Would it be

    ::Asset name PARMS parm1 parm2..parmN

    I never intended the % to be taken literaly. Any text that you wanted as a target for substitution could be there, for instance

    ::Asset sentence verb colour animal1 animal2 adjective
    The Quick colour animal verbed over the adjective animal2

    could be retrieved by ?~sentence('jump','brown','fox','dog','lazy')

    I would say that the data that follows includes the NL characters except the last one. Alternatively the results could be returned as an array, like with the method method.

    All the applications I can think of would want the NLs respected, but maybe that is just my limited imagination?

    Binary data - good question. Two suggestions
    1) only allow Ascii (or whatever the sourcefile is encoded in) - the user can then convert using X2C
    2) just store whatever is there up to the end of file or next directive. The user has to use their ingenuity to get the data into the sourcefile.

    Jon

     
  • Gil Barmwater

    Gil Barmwater - 2013-05-19

    From the Ref: "The ::CONSTANT directive creates methods that return constant values for a class and its instances." So making ::ASSET "floating" would require something more like floating methods, accessed via .METHODS[name]. That seems to be OK to me as I see an asset sort of like an attribute with only a GET method.

    I was following up on Rony's comment about subkeywords so it seems that your PARMS example would work plus it would allow other subkeywords like: NONL (would take each line in the body and abut them to form a single string) and BASE64 (implies NONL but also specifies that the string is encoded).

    I still have some reservations about substitution of parms in the body as it seems there could be some ambiguous cases.

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-05-19
    • status: unread --> open
     
  • Rick McGuire

    Rick McGuire - 2013-11-20
    • Milestone: v4.2.0 --> None
     
  • Rick McGuire

    Rick McGuire - 2014-06-29
    • status: open --> accepted
    • assigned_to: Rick McGuire
    • Pending work items: none --> code+doc+test
     
    • Jon Wolfers

      Jon Wolfers - 2014-06-29

      Hi Rick,

      thanks for taking this on. I'm sure it will be an 'asset' to the language
      :->

      Jon

      On 29 June 2014 20:35, Rick McGuire bigrixx@users.sf.net wrote:

      • status: open --> accepted
      • assigned_to: Rick McGuire
      • Pending work items: none --> code+doc+test

      Status: accepted
      Milestone: None

      Created: Thu May 16, 2013 04:46 AM UTC by Jon Wolfers
      Last Updated: Wed Nov 20, 2013 06:21 PM UTC
      Owner: Rick McGuire

      Following on from Frank Clarke's presentation to the 2013 Symposium, I
      wonder if users would benefit from an ::Asset directive. It would function
      much as the ::Constant directive, but the value would be whatever was on
      the subsequent source lines up to the next directive or end of file. The
      parser would treat these lines as comment.

      This could be used for panel data as per Frank's presentation, or sql
      queries or user instructions or a host of other things

      made up example

      ::class queries
      ::Asset Margin
      Select profit - costs as margin
      from balancesheet
      ::Asset liability
      select cost
      from balancesheet
      where profit > 0

      The string value of the asset could be retrieved by .class~AssetName ie
      .queries~Margin

      An added bonus would be the ability to substitute values on retrieval, but
      perhaps that would over-complicate matters.

      ::class queries2
      ::asset sales %startdate %enddate
      select sum(amount)
      from sales
      where invoicedate >= '%startdate'
      and invoicedate <= '%enddate'

      the substitution argument(s) can be any string and the passed parameters
      are substituted for it wherever it appears in the asset at retrieval time

      qry = .queries2~sales('2012-01-01','2012-03-31')

      would return the string
      select sum(amount)
      from sales
      where invoicedate >= '2012-01-01'
      and invoicedate <= '2012-03-31'

      What do you think?

      thanks Jon

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/oorexx/feature-requests/545/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Feature Requests: #545

  • Rick McGuire

    Rick McGuire - 2014-09-25
    • Pending work items: code+doc+test --> doc+test
    • Milestone: None --> 5.0.0
     
  • Erich

    Erich - 2015-06-13

    ::RESOURCE documented in revision [r10915].

     

    Related

    Commit: [r10915]

  • Erich

    Erich - 2015-06-13
    • Pending work items: doc+test --> tests
     
  • LesK

    LesK - 2015-06-13

    How would a Classic Rexx programmer like myself use this to, for instance,
    retrieve 'boilerplate' code to insert into a new .rex file from THE?

    Or, as another example, retrieve lines of HELP text, substitute variables and then be able to display the lines (somehow).

    I currently do both of these using comment markers and sourceline(), but this idea might make it simpler!

     
    • Erich

      Erich - 2015-06-13

      How would a Classic Rexx programmer like myself use this
      retrieve lines of HELP text

      For example like this:

      parse arg arguments
      if arguments = "" | arguments~strip~caselessEquals("--help") then
      say .resources["USAGE"]~makeString

      ::resource usage
      Usage:
      commmand [options] file

      options:
        --help     displays this help
        --other
      
      file         specifies the input file to be processed
      

      ::END

      On Sat, Jun 13, 2015 at 11:18 PM, LesK vmrexx@users.sf.net wrote:

      How would a Classic Rexx programmer like myself use this to, for instance,
      retrieve 'boilerplate' code to insert into a new .rex file from THE?

      Or, as another example, retrieve lines of HELP text, substitute variables
      and then be able to display the lines (somehow).

      I currently do both of these using comment markers and sourceline(), but
      this idea might make it simpler!


      [feature-requests:#545] Asset Directive

      Status: accepted
      Milestone: 5.0.0
      Created: Thu May 16, 2013 04:46 AM UTC by Jon Wolfers
      Last Updated: Sat Jun 13, 2015 08:30 PM UTC
      Owner: Rick McGuire

      Following on from Frank Clarke's presentation to the 2013 Symposium, I
      wonder if users would benefit from an ::Asset directive. It would function
      much as the ::Constant directive, but the value would be whatever was on
      the subsequent source lines up to the next directive or end of file. The
      parser would treat these lines as comment.

      This could be used for panel data as per Frank's presentation, or sql
      queries or user instructions or a host of other things

      made up example

      ::class queries
      ::Asset Margin
      Select profit - costs as margin
      from balancesheet
      ::Asset liability
      select cost
      from balancesheet
      where profit > 0

      The string value of the asset could be retrieved by .class~AssetName ie
      .queries~Margin

      An added bonus would be the ability to substitute values on retrieval, but
      perhaps that would over-complicate matters.

      ::class queries2
      ::asset sales %startdate %enddate
      select sum(amount)
      from sales
      where invoicedate >= '%startdate'
      and invoicedate <= '%enddate'

      the substitution argument(s) can be any string and the passed parameters
      are substituted for it wherever it appears in the asset at retrieval time

      qry = .queries2~sales('2012-01-01','2012-03-31')

      would return the string
      select sum(amount)
      from sales
      where invoicedate >= '2012-01-01'
      and invoicedate <= '2012-03-31'

      What do you think?

      thanks Jon


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/oorexx/feature-requests/545/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

      Related

      Feature Requests: #545

  • Erich

    Erich - 2016-04-27
    • status: accepted --> pending
    • Pending work items: tests --> none
     
  • Erich

    Erich - 2016-04-27

    Committed tests with revision [r11026]

     

    Related

    Commit: [r11026]

  • Rony G. Flatscher

    • Status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel