>I've been dabbling in different languages lately (Python, Ruby on Rails, C#, etc.) and one thing I found that I really like with Ruby is the sequential in-line function calls.
>
>In VFP we work inside out which isn't easy to read:
>
myudf(padr(trim(str(lnVariable)),10))
>
>In Ruby (using VFP methods) the same thing would be like this:
>
lnVariable.str().trim().padr(10).myudf()
>
>The sequential way is SO much more readable. Here's my question. Generically, what do you call this difference/paradigm (as I'm sure it's not called Sequential In-Line Function Calls) ?
>
>Secondly, how easy would it be to create this capability in VFP?
>
>Here's a really short (and bad) sample that illustrates the idea.
>
>** SILF.prg - Sequential In-Line Function
>** Allow us to make Ruby type calls
>** lxValue = original source value
>** lcF = functions calls use pipe | for proper variable placement
>**
>** Example call: SILF(5,[STR(|).ALLTRIM(|).PADL(|,3,'0')])
>LPARAMETERS lxValue,lcF
>
>LOCAL lnX,lnFCount,lxReturnValue
>lnFCount=GETWORDCOUNT(lcF,[.])
>lxReturnValue=lxValue
>
>FOR lnX=1 TO lnFCount
> lxReturnValue=EVALUATE(STRTRAN(GETWORDNUM(lcF,lnX,[.]),[|],[lxReturnValue]))
>ENDFOR
>
>RETURN lxReturnValue
>
>
The VFP syntax is a natural expression of wrapper functions. Your sample Ruby syntax is piped. Both syntaxes are perfectly legitimate and widely used (piping perhaps more in *n?x systems).
Readability - I have no problem with either, but I'm used to working inside-to-out because I cut my programming teeth on an RPN HP calculator. YMMV.
I don't see any advantage to supporting piped function calls for VFP, especially if the function has to be called with a carefully constructed string with pipe symbols, square brackets etc.
Does it handle the case where a VFP function has multiple parameters (which may or may not be optional), and two or more parameters themselves are VFP function calls?
I suspect hardening your routine to handle inputs that contain string delimiters and periods might be a PITA.
I'm thinking the whole concept would be a maintenance nightmare for anyone but you.
Last, but certainly not least, SILF is too close to MILF :)
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up