Comments (8)
value?
is fine, and correctly throwing an error. You need to pass a word!
to it, where the errors clearly tell you that you aren't. Try n: 23 value? 'n
. You need to understand evaluation. Just as important, please use Gitter to ask if things are bugs, after you've seen if there's already a ticket for them, before opening tickets.
from red.
So this is Reddish behavior? It differs from REBOL 2.7.8 and Rebol 3
REBOL 2.7.8
>> value? 12
== true
>> value? #{0A6B14728C4DBEF5}
== true
Rebol 3
>> value? 12
== true
>> value? #{0A6B14728C4DBEF5}
== true
But in Red 0.6.5
>> value? 12
*** Script Error: value? does not allow integer! for its value argument
*** Where: value?
*** Near : value? 12
*** Stack:
>> type? #{0A6B14728C4DBEF5}
== binary!
>> value? #{0A6B14728C4DBEF5}
*** Script Error: value? does not allow binary! for its value argument
*** Where: value?
*** Near : value? #{0A6B14728C4DBEF5}
*** Stack:
Isn't value? 'n
merely asking the interpreter if a literal value is an irreducible value, i.e., a symbol of itself?
from red.
Your answer seems to be wrong, unless it a design decision for Red. Here is why:
>> value? 'zzz
== true
>> ?? zzz
zzz: unset!
>> get zzz
*** Script Error: zzz has no value
*** Where: get
*** Near : get zzz
*** Stack:
from red.
@TimeSeriesLord Seems you are using an old version of Red.
>> value? 'zzz
== false
>> ?? zzz
zzz: unset!
>> about
Red 0.6.5 for Windows built 6-Apr-2024/8:45:40+08:00 commit #36adc61
from red.
@TimeSeriesLord noted that it was a recent build in their first message. Hmmm.
from red.
Isn't value? 'n merely asking the interpreter if a literal value is an irreducible value, i.e., a symbol of itself?
No, because value?
uses a "normal" argument, so when you call it, the argument is evaluated and value?
only takes word!
values. So you need to pass a lit-word!
or value? first [...]
to pass the word itself. Then value?
can see if that word is set.
This is by design because everything in Redbol langs is a value so that's sort of meaningless. The doc string also makes it clear that we're talking about what a word refers to. It's still a little confusing and should be improved when we do the red specs project to clearly define more details. That is, everything is a value, but unset!
is special in that it's sort of a non-value that exists largely for implementation reasons. The confusing part is that unset!
is truthy (only false
and none
are falsy).
I thought it was discussed, but can't find it now, to use set?
instead of value?
as the name, and deprecate the former. That would make it much clearer.
e.g. in R2 you get this, because none!
is a value, even though the doc string said "Returns TRUE if the word has been set.".
>> value? pick [] 1
== true
Which makes no sense.
from red.
Well thanks, Gregg! So in Red, value? functions differently than in REBOL 2.7.8 or Rebol 3.
In the latter two, value? sort of meant "has value" or "reducible to value".
In Red 0.6.5, it means "only if a word is set to another word, which might or might not be set to a value of some kind, e.g., an irreducible value, a function."
from red.
Not set to another word, but referring to anything other than unset
. Here is the actual source code: https://github.com/red/red/blob/master/runtime/natives.reds#L2022
In Red it works roughly like this
set?: func [val [word!]][not unset? get/any :val]
Now, if we add some debug logic, it should be even more clear.
set?: func [
val [word!]
][
print [mold type? :val :val mold type? get/any :val]
not unset? get/any :val
]
And some examples:
>> set? 'xxx
word! xxx unset!
== false
>> set? 'pi
word! pi float!
== true
>> my-word: 'xxx
== xxx
>> set? 'my-word
word! my-word word!
== true
>> set? my-word
word! xxx unset!
== false
from red.
Related Issues (20)
- Using point2D! as SIZE for a TAB-PANEL makes its children not to be shown.
- GROUP-BOX frame is not always conforming to its size. HOT 3
- view in 0.65 : word result is not local
- False Positive! HOT 1
- Inside part of TAB-PANELs do not resize. HOT 2
- Extra slashes in file/url composition
- The IMAGE STYLE doesn't get its face color. HOT 9
- Custom panel actors completely overwrite the actors object. HOT 4
- MSDOS support, really? (Feature Request/Fix, or should rename the --target) HOT 6
- Words fail to stay local in blocks evaluated with loop block evaluator: repeat HOT 3
- Words fail to stay local in blocks evaluated with loop block evaluators: foreach HOT 3
- WISH: DRAW command PEN should have option DOTTED HOT 3
- Point to point conversions are buggy HOT 1
- VID area blocked and slow on big text HOT 8
- New fix for area does not work with WRAP HOT 13
- `round/even/to` doesn't work on `money!`
- 16-bit vector! math error HOT 1
- [Regression] CLI console can't be compiled with the native GUI backend
- VID on Ubuntu doesn't right align HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from red.