World: r3wp
[!REBOL3]
older newer | first last |
BrianH 2-May-2010 [2492x2] | ChristianE, It seems like an oversight to me. We aren't doing the SQL-style "null doesn't equal anything, even other nulls" model in REBOL. |
Pekr, sorry, you did mention "or function" :) | |
Pekr 2-May-2010 [2494x2] | :-) |
BrianH: time to push protect related bugs for implementation, no? Aren't they keeping us back from having security fixed? | |
Graham 2-May-2010 [2496] | about time ... empty? none |
Pekr 2-May-2010 [2497] | yes, done ... |
Henrik 2-May-2010 [2498] | hmm... diffferent solution from my NEUTRAL? suggestion. |
BrianH 2-May-2010 [2499] | Yes, protect bugs, but not for a98. It's actually been good to put them off: It's given us more time to really think about them. Security is a hard topic. Unfortunately, my proposed changes are flexible enough, but will need a lot of chaining to get the right pattern and recommended chaining patterns will need documenting. |
Graham 2-May-2010 [2500] | I use this something?: func [ o [any-type!]][ all [ o not empty? o ] ] |
BrianH 2-May-2010 [2501x2] | I would like to come up with a simpler solution that anyone can get, but I'm afraid this is likely not possible given the topic. |
Graham, you would need to either refine the code or the typespec. That's not right for most types, and not safe for function types. | |
Graham 2-May-2010 [2503x2] | I just use it for series |
something?: func [ o [series! none!]][ all [ o not empty? o ] ] | |
BrianH 2-May-2010 [2505] | Ah, good, then it's the typespec that would be refined :) |
Graham 2-May-2010 [2506] | bette? |
BrianH 2-May-2010 [2507x2] | (you beat me to it) Yes :) |
With the revised EMPTY? you could do this: false = empty? o | |
Graham 2-May-2010 [2509x2] | something is better than nothing |
nothing? is not something? | |
BrianH 2-May-2010 [2511] | Something is only better than nothing in some circumstances. "What's wrong?", "Something" :( |
Graham 2-May-2010 [2512x3] | for me nothing is an empty series or null |
actually I would prefer that empty? also is true on a series containing spaces only ... | |
when proceessing input | |
BrianH 2-May-2010 [2515x2] | It's good that you have that function then. I prefer to think that an empty series or a series full of spaces is something, and that none is nothing. |
However, it may not be the something you want. | |
Graham 2-May-2010 [2517x3] | Basically when doing forms you need to detect if the user has entered something |
and a series of spaces is not something | |
it might be the cat walking on the space bar | |
BrianH 2-May-2010 [2520] | Yup. Different topic than what EMPTY? covers though. |
Graham 2-May-2010 [2521] | Yeah ,... much to do about nothing |
BrianH 2-May-2010 [2522] | :) |
Pekr 2-May-2010 [2523] | Graham - then use empty? trim value to remove spaces :-) |
Graham 2-May-2010 [2524] | trim is destructive |
Pekr 2-May-2010 [2525x2] | trim copy then :-) |
I know that copy is an overhead, but forms are of finite length, so I would not worry about performance. I used empty? trim copy value idiom in the past ... | |
BrianH 2-May-2010 [2527] | Wait, your user input functions don't allocate a new string each time? Why else should you care if trim is destructive? |
Graham 2-May-2010 [2528] | more then just keyboard input ... |
BrianH 2-May-2010 [2529x2] | Sorry, nevermind then. |
Carl just posted this code, to be the new definition of EMPTY?: empty?: make :tail? [ [ {Returns TRUE if empty or NONE, or for series if index is at or beyond its tail.} series [series! gob! port! bitset! map! none!] ] ] This means two things, one minor, one major: - Minor: TAIL? won't take none, so we have an option of triggering the error if need be. - Major: *You can do that kind of thing at all*. This opens a *lot* of possibilities :) | |
Graham 2-May-2010 [2531] | make tail? interesting |
Steeve 2-May-2010 [2532] | Wow, i like this strick, I will use it everywhere i can |
BrianH 2-May-2010 [2533] | I wonder what the effect will be on function! and closure! functions, whether there is body copying. It seems like a really interesting way to do optional arguments to commands though. |
Steeve 2-May-2010 [2534] | But it's a litlle obfuscated. |
BrianH 2-May-2010 [2535x4] | I expect that the best use will be either making is-it-an-error-or-not changes like the above, or simplified versions of functions, perhaps for sandboxing. So remember this: If you have a nice, friendly native function with some advanced, evil options, put the most evil ones at the end of the list, so they can be hidden later if need be. |
Or, alternatively, we may have to block this in sandboxed code so it isn't used to break the sandbox. | |
safe-make: make :make [[ "Constructs a specified datatype." type [datatype! any-object!] "The datatype or example value" spec [any-type!] "The attributes of the new value" ]] | |
And add more datatypes to the spec as testing determines them to be safe. | |
Steeve 2-May-2010 [2539x2] | Wait.... I need to disgest that insanity at first... make :make... |
I'm tired.... You could give me some time... | |
BrianH 2-May-2010 [2541] | Compare spec-of :make to see the difference. |
older newer | first last |