r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Graham
27-Jul-2009
[14335]
That's my issue ... because the standard for the data has not been 
tightly defined, there are varying implementations leading to somewhat 
variable structures
BrianH
27-Jul-2009
[14336]
Sounds like you need a tighter definition, or to resign yourself 
to slow code.
Graham
27-Jul-2009
[14337]
It's an ASTM standard ... I can't change the XSD!
BrianH
27-Jul-2009
[14338]
But you can use a consistent REBOL representation of it, and don't 
need objects.
Graham
27-Jul-2009
[14339]
Google health has solved the issue by only working with a subset 
of the XSD.
BrianH
27-Jul-2009
[14340]
Well, you can clean it up to a usable structure on read, process 
it nicely, then regenerate the bad XML on write.
Graham
27-Jul-2009
[14341x2]
Yeah .. I guess I was getting to that.
I suspect this is a very common issue and not bad xml.  So, if the 
XSD states an element can be 0 ... n and each element can be of a 
different type, then it's going to be difficult to work with no matter 
what.
BrianH
27-Jul-2009
[14343]
If an XSD states that; it should always be a block even in the single 
object case.
Graham
27-Jul-2009
[14344]
I guess the xml-to-object.r script doesn't know that!
BrianH
27-Jul-2009
[14345x4]
I never liked that script :(
(no offence intended to whoever wrote it)
Saw a new language the other day that has a native, literal data 
structure which matches the XML object model, without the syntax.
Nice language - clean and small, pretty to look at, compiles to native 
code.
Graham
27-Jul-2009
[14349x3]
Given 


>> obj: make object! [ Description: make object! [ Text: "REBOL" 
]]
>> path: 'Description/Text
== Description/Text


How can I find "REBOL" without breaking the path into it's constituents?
I'm guessing that there's something very simple ... but in the meantime


get-value: func [ obj [object!] path [path!]
	/local id
][
	if not empty? path [
		either all [ id: in obj path/1  obj: get id  object? obj ][
			remove path
			get-value obj path
		][
			obj
		]
	]
]
>> get-value obj path
== "REBOL"
Ashley
29-Jul-2009
[14352x2]
Is this a bug or a feature:

>> to integer! ""
== 0
>> to decimal! ""
** Script Error: Invalid argument:
** Near: to decimal! ""
Henrik
29-Jul-2009
[14354]
R3 returns a bug with the first one, but it could be intentional 
in both R2 and R3.
BrianH
29-Jul-2009
[14355]
It was an intentional change. TO has been cleaned up a lot in R3 
- the error there tells why:
>> to integer! ""
** Script error: content too short (or just whitespace)
Sunanda
29-Jul-2009
[14356x2]
R2 also works with
  to integer! #
but  not
  to integer! %
Looks like a consistency bug in R2 that has been fixed in R3.
Oops -- Brian beat me to, and gave the definitive answer to trump 
my late speculation.
BrianH
29-Jul-2009
[14358x2]
The R2 behavior is more of a "feature": Buggy behavior that you can 
count on remaining in R2 for compatibility reasons.
Almost every day I come across another reason to appreciate bug#666 
:)
Graham
4-Aug-2009
[14360x2]
How can i redefine 'now so that it takes into account an offset ( 
which is only calculated once ) .. without causing a stack overflow!
I guess I need to copy the function block of 'now ... but can you 
do that with natives ?
BrianH
4-Aug-2009
[14362x2]
SPEC-OF works on natives too :)
Remember to keep a private reference to the old NOW, or at least 
reference it through system/contexts/system/now. When you set 'now 
in a user script it will copy the value of 'now to the user context 
(system/contexts/user), and then you will be reassigning it there.
Graham
4-Aug-2009
[14364x2]
spec-of ??
sounds like a R3 function
BrianH
4-Aug-2009
[14366x4]
Oh, sorry, I backported it. Try this instead:
    copy/deep third :now
I forget sometimes when R2 doesn't have the new functions since I 
mostly work with R2/Forward (the backports).
And isnore the user-vs-system context thing too.
isnore -> ignore
Graham
4-Aug-2009
[14370]
you're having a dyslexic day :)
BrianH
4-Aug-2009
[14371]
Bad typing day :(
Graham
4-Aug-2009
[14372]
at least the hair is good
BrianH
4-Aug-2009
[14373]
It is :)
Graham
4-Aug-2009
[14374]
third :now only gives me a block
BrianH
4-Aug-2009
[14375]
You use that block as the spec block of your new function. Save a 
reference to the old, and then call it in your new function from 
your saved reference. Natives don't have body blocks.
Graham
4-Aug-2009
[14376]
too hard!
Gabriele
4-Aug-2009
[14377x2]
do you need all the refinements to work? otherwise, just make a fixed-now 
function or something like that.
if you need al refinements to work, you'll have to pass them on. 
easiest way is to grab some version of APPLY and use that.
Graham
4-Aug-2009
[14379x3]
Yes, need the refinements too
I want a drop in replacement 'now that also accesses a fixed time 
offset that is calculated at program start up.
I am using Ladislav's get-nist-correction
BrianH
4-Aug-2009
[14382]
That's tricky to do without R3 or R2/Forward - the number of comparisons 
is exponential to the number or refinements.
Gabriele
4-Aug-2009
[14383]
since you have to always add the offset, you're actually always calling 
the native without any refinements (or maybe with /precise), then 
you add the offset, and only then you "apply" the refinements (eg. 
return the year if /year was used)
Graham
4-Aug-2009
[14384]
yes. that's what I was trying.