Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 13 2016 03:25
    @PeterWAWood banned @Vexercizer
Vladimir Vasilyev
@9214
@BeardPower = b/:offset part.
BeardPower
@BeardPower
Yep.
Will it ever be able to compile that?
I got rid of the :
Vladimir Vasilyev
@9214
@BeardPower as I understand you have a block of records that you want to sort by some field?
BeardPower
@BeardPower
Yes. It's a REBOL example for implementing a simple db.
using a/offset will compile.
Vladimir Vasilyev
@9214
I will, but that's not what you want.
BeardPower
@BeardPower
If offset is an integer : and no : will have the same outcome.
Vladimir Vasilyev
@9214
I'd rather use something like this. Records 2 values in width, sorted by 2nd column.
>> sort/skip/compare [a 3 b 1 c 2] 2 2
== [b 1 c 2 a 3]
BeardPower
@BeardPower
Why I won't want getting rid of the :?
Thanks. Yeah, that looks nice.
Vladimir Vasilyev
@9214
@BeardPower a/offset uses offset literally as a key. a/:offset uses whatever offset is set to as a key or index, in your case it's an integer index.
BeardPower
@BeardPower
Yes, so it will work as the offset will never be something different than an integer.
Vladimir Vasilyev
@9214
@BeardPower
>> block: [database record at offset 123]
== [database record at offset 123]
>> offset: 2
== 2
>> block/offset ; offset is a key that selects 123
== 123
>> block/:offset ; offset is set to 2 that is used to fetch 2nd value
== record
Gregg Irwin
@greggirwin
@BeardPower but Red doesn't know that, because variables aren't typed.
Technically, with enough effort, yes, the compiler could see that the only values a word might refer to in a given scenario are of a given type, and optimize based on that, or compile at all.
BeardPower
@BeardPower
@greggirwin But index? will return an integer. So wouldn't it work all the time?
So using /offset would always work and it would always compile.
Vladimir Vasilyev
@9214
@BeardPower take a look at my example. It will compile, but won't work as you want.
Gregg Irwin
@greggirwin
Only if the compiler examines everything to see that you have thrown in a offset: 'gotcha! line in the middle of the func. Or anything else that could potentially return a non-int.
BeardPower
@BeardPower
@9214 Yes, but index? will always return an integer so it will always be exactly what I want: the key, in which my case is an integer.
Vladimir Vasilyev
@9214
@BeardPower if you use :offset that does not compile. If you use offset that compiles then the key will always be offset, regardless of what index? returns.
BeardPower
@BeardPower
Yes, and it will be an integer: offset: find fields field
As find will return an integer.
And index?
offset is set by index?, so why would it be offset regardless of what index? returns?
Vladimir Vasilyev
@9214
BeardPower
@BeardPower
Ah, now I get it. You mean that it will refer to the key inside the block.
Vladimir Vasilyev
@9214
@BeardPower precisely.
BeardPower
@BeardPower
Thanks!
Sorry, it's a little late and time for some sleep hehe
Vladimir Vasilyev
@9214
So, try do [a/:offset = b/:offset] instead.
BeardPower
@BeardPower
Will do.
That did it hehe
X.A.N.O.Z.O.I.D.
@XANOZOID
I saw that a community member recently added #4656 . . . I saw that #3488 was closed with a comment. So what kind of discussion has there been on WASM thus far? One of the #/1 targets I'd like to see for Red is definitely going to have to be WASM. Anyone else actually interested in this target? I haven't seen any other WASM related posts on the Red Github page -- but I'm willing to take a look into the possibility of implementing, or starting the effort of implementing, a WASM target.
X.A.N.O.Z.O.I.D.
@XANOZOID
However, I'm hoping this is actually reasonable. How much of Red is separated from Rebol, and to what point are they able to be separated? Also, does Red currently compile to other platforms by actually understanding how to translate itself (well R/S I suppose) to each architectures/target's machine code? Or are there intermediate steps? I don't imagine Red "assembles itself" for any target, but really only needs to understand how to create the necessary machine code per target. Well, I'm thinking that is of course unless some "assembly" happens to be the "target" for any reason.
Boleslav Březovský
@rebolek
Adding NetBSD is much easier than WASM, look at the changeset, it basically adds NetBSD to list of systems and few support functions. Adding WASM means adding whole new "cpu" architecture.
There certainly are people interested in WASM version of Red but no one hasn't started any work on it AFAIK. It is usualy discouraged as current compiler will be thrown away but I believe that once new compiler is in place, lot of old code could be reused.
So if you are interested in doing it and aren't afraid rewriting it once the currenten compiler is abandoned, go for it! :-)
Regarding the separation, Red is translated to Red/System (this step is done in Red) and the Red/System is compiled to machine code (compiler is written in Rebol).
So adding new architecture (WASM) means extending the compiler so it can compile Red/System to WASM.
X.A.N.O.Z.O.I.D.
@XANOZOID
@rebolek Ahh okay . . . I'm very much interested in doing something like this. Perhaps I could just make a "tech-demo" in my spare time under a limited dialect of my own . . . but creating the "red runtime" might not be a possibility for me at this point haha
@rebolek Thank you!! Well, I'm definitely interested. No problem in the compiler being "thrown" away if my efforts make future "wasm" efforts much more streamlined! And of course there's always the fact that the old version may be useful until newer versions support wasm again :)
Boleslav Březovský
@rebolek
The tech demo would be something like print "hello world" in Red/System. You don't have to cover Red runtime at all - once you can compile Red/System, you get Red for free :-)
X.A.N.O.Z.O.I.D.
@XANOZOID
I'm at least interested to say the least 😊
Boleslav Březovský
@rebolek
:-)
Respectech
@Respectech
I am also interested in WASM as a target.
X.A.N.O.Z.O.I.D.
@XANOZOID
One issue I'm having on deciding where I'll put this effort is the fact some important things about the WASM target don't have a full standard yet. Specifically, modules (dynamic libs) are still a work in progress. So any effort made to try to make a Red module interface with LLVM/C++ generated WASM might not be very stable. However, LLVM related WASM efforts are apparently being done in parallel with C/C++ efforts for WASM compilation. . . If that's the case, what's the talk around in the Red community about LLVM? It might make more sense, in terms of covering more ground with less initial work, to target LLVM assembly or bitcode instead of WASM code. Again . . . Thoughts? This talk is about my own efforts vs where the limited resources of the official Red team/community goes btw. Until I get something off the ground in the future of course 😄
Oldes Huhuman
@Oldes
If you don't know what to do with your available time.. than making LLVM target is better investement than direct wasm code.
Btw.. for example Adove was using LLVM to crosscompile its ActionScript into iOS native code.
Gregg Irwin
@greggirwin
@XANOZOID we plan to have an LLVM back end at some point. While our primary goal is to rely on externals as little as possible (i.e. just the OS), LLVM has enough value in platforms and optimizations that we feel it's worth it. It's a big task, so looking at how Red's compiler emits target code, and starting with hello world as was noted, is a good first step.
X.A.N.O.Z.O.I.D.
@XANOZOID
Awesome, I'll keep all of this in mind going forward 🙂. LLVM is probably what I'll really dig into - but if not WASM is not out of the picture.