Structures and routines

Examples are from under OS X. If the code here wants to be copy/pasted to the World prompt, turn auto-brackets off with Ctrl-A in World.

The libc routine gettimeofday returns the current calendar time as the elapsed time since the epoch. It takes pointers to two structures as arguments and fill those structures with data.

First libc needs to be loaded:

    w> libc: load/library %/usr/lib/libc.dylib

Then the structures and routine are defined:

    timeval: struct [
        slong sec
        sint32 usec
    ] none

    timezone: struct [
        sint minuteswest
        sint dsttime
    ] none

    gettimeofday: routine [
        libc "gettimeofday" [
            tp [struct!] pointer
            tzp [struct!] pointer

gettimeofday can now be called:

    w> gettimeofday timeval timezone
    == 0

timeval and timezone then holds the data. The routine localtime_r takes time and a struct tm as arguments and fill the structure with data:

    tm: struct [
        sint sec
        sint min
        sint hour
        sint mday
        sint mon
        sint year
        sint wday
        sint yday
        sint isdst
        slong gmtoff
        pointer zone
    ] none

    localtime-r: routine [
        libc "localtime_r" [
            time [struct!] pointer
            resultp [struct!] pointer
        pointer handle!

The time argument is a pointer to a slong holding the seconds. But that's the first variable in the timeval structure, so we can just pass that:

    w> localtime-r timeval tm

Now tm is filled with data, and we can e.g. get the day of the year:

    w> tm/yday
    == 353

There is some freedom in defining structures. C datatype and argument name can be exchanged. It's also possible to give initial values, so these two are the same:

    struct [float f] [1.0]
    struct [f float] [1.0]

Now find some more interesting libraries to integrate with!


  1. Integrates with OpenCOBOL runtime and compile shared modules.

  2. That's cool, Brian! I would like World to integrate with lots of other technologies, both World calling others, and others calling into World. The former is possible for example with these routines, the latter is yet to come.

  3. Wow. I had played a bit with Red, but this is also amazing. Just playing with parse and seems very complete.
    I was getting worried about the state of rebol and now there are two excellent projects to take the ideas forward. Keep up the great work and thank you :-)

  4. Very nice. This will help make World a great glue language.

  5. This comment has been removed by the author.

  6. do you continue developing world? I like it but haven't seen a post for a long time

  7. Yes, World is still being developed, but as I finance the development myself, I had to take time away from the project. A new version is available, so use the "Get World" link at the top to get this. I may put some new blog posts up soon.

  8. Hey there, You have done a fantastic job. I will certainly digg it and personally suggest to my friends. I’m confident they’ll be benefited from this website.
    C Programming Courses in Chennai

  9. Nice blog..! I really loved reading through this article. Thanks for sharing such a amazing post with us and keep blogging...Well written article share more
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

  10. First and foremost, make sure both parents are on the same page and respond in similar ways to poor behavior, implementing the same structure and discipline for specific behaviors in

  11. With special privileges and services, UEFA BET offers opportunities for small capitalists. Together ufa with the best websites that collect the most games With a minimum deposit starting from just 100 baht, you are ready to enjoy the fun with a complete range of betting that is available within the website

    ufabet , our one another option We are a direct website, not through an agent, where customers can have great confidence without deception The best of online betting sites is that our Ufa will give you the best price

    หาคุณกำลังหาเกมส์ออนไลน์ที่สามารถสร้างรายได้ให้กับคุณ เรามีเกมส์แนะนำ เกมยิงปลา รูปแบบใหม่เล่นง่ายบนมือถือ คาสิโนออนไลน์ บนคอม เล่นได้ทุกอุปกรณ์รองรับทุกเครื่องมือ มีให้เลือกเล่นหลายเกมส์ เล่นได้ทั่วโลกเพราะนี้คือเกมส์ออนไลน์แบบใหม่ เกมยิงปลา

    อีกทั้งเรายังให้บริการ เกมสล็อต ยิงปลา แทงบอลออนไลน์ รองรับทุกการใช้งานในอุปกรณ์ต่าง ๆ HTML5 คอมพิวเตอร์ แท็บเล็ต สมาทโฟน คาสิโนออนไลน์ และมือถือทุกรุ่น เล่นได้ตลอด 24ชม. ไม่ต้อง Downloads เกมส์ให้ยุ่งยาก ด้วยระบบที่เสถียรที่สุดในประเทศไทย

  12. one fast brownIn case you are looking for a good site, UFA, UEFA Bet casino site. Which can be played as a thorough answer, in a position to answer Quality and Performance It's ideal to get a great deal of the issues. It can be something very punching and fascinating. Excellently, the items that UFABET football betting is absolutely nothing even with the practical experience of quality. Plus accessibility that are able to see final results It's a model that is very sharp and also different. Full of performance of creating wealth Attractiveness With the most beneficial opportunities it is quite nothing You will find opportunities and also probabilities for making profits. Quality and also somewhat diverse For people who have come to make use of the service excellently fox

  13. Also, there are some acceptable ones out there as well! I'm simply more knowing with regards to where I invest my energy and cash now and I quit pursuing the following sparkly proposition." Programming Language Help Online.

  14. Took me technology to entre all of the observations, however I absolutely loved the article. It proved to be Very cordial to me and i am unconditional to all the commenters here! Its constantly clean whilst you can't on your own be informed, however with entertained! Avast Driver Update Activation Code

  15. What a fantabulous observe this has been. in no way seen this understandable of beneficial claim. i'm grateful to you and assume more quantity of posts at the side of those. thank you intensely a lot. Happy Brothers Day Quotes From Sister

  16. This comment has been removed by the author.

  17. This comment has been removed by the author.

  18. Thanks for sharing some useful and impressive topics in your blog post...We provide best iot mini project centers in chennai and we have excellent .net project centers in chennai visit our website for your projects...

  19. The blog was useful in knowing about book life.Excellent blog thanks for sharing the valuable becomes easy to read and easily understand the information.Create you own project from usstudent projects in chennai

  20. pg slot เว็บใหม่ พวกเราเป็นเว็บไซต์สล็อต ไม่ผ่านเอเย่นต์ ที่คนนิยมเล่นมากที่สุด จะต้องชูให้เว็บไซต์ PG-SLOT.GAME ยืน 1 เว็บไซต์ตรง pg slot วันนี้พวกเราอัปเดตเว็บไซต์ใหม่