<b4284>i'm wondering how to work with fixed-sized integers on guile <b4284>especially with signed integers <b4284>i read the manual and it says the bitwise functions treats negative integers as if there are infinite ones on the left <b4284>no, i'm not working with ffi <mark_weaver>if it's storage efficiency that you need, there are srfi-4 homogeneous numeric vectors, which we support well <b4284>i wanted to revert the bits of an int32 <mark_weaver>at the scheme level, we actually don't currently support doing fixed-width math directly <mark_weaver>so, srfi-60 (integers as bits) allows you to do bitwise operations on scheme's unlimited-size integers <mark_weaver>and actually, guile already has equivalent functionality in the default environment (no need to import anything), but those aren't portable <b4284>(bitwise-not #xffffffff) gives -4294967296, i was expecting an 0 <b4284>i must have missed something <mark_weaver>these are not fixed-width integers, they are unlimited length <mark_weaver>but still interpreted as twos-complement for purposes of these operations <mark_weaver>so, one way to think of it is that since the positive number #xffffffff cannot fit in a 32-bit signed integer, it is upgraded to a large size automatically. <mark_weaver>with these unlimited-size integers, a positive number will never become negative due to overflow, which is the behavior in C that you are depending on here to expect #xffffffff to be equal to -1 <mark_weaver>b4284: if you need to import numbers like #xffffffff, you need to sign-extend the high-bit, just as you would when converting from int32_t to int64_t <b4284>ok, let me chew on it for a while <mark_weaver>in guile, you can do that sign extension like this: (centered-remainder #xffffffff (expt 2 32)) <b4284>mark_weaver: i'm just typing and printing it out to figure out its behavior <b4284>mark_weaver: wow, never thought there's a function like centered-remainder <mark_weaver>there are several different variants of DIV and MOD in guile <mark_weaver>'centered-remainder' should also simulate the effect of overflow for signed addition and subtraction at least, and probably also multiplication, although I'm not quite sure about that. <mark_weaver>however, that is the effect of signed overflow in the hardware. in practice, C now has different behavior on signed overflow. <mark_weaver>modern C compilers are allowed to assume that signed overflow will never happen, and aggressively optimize the code based on that assumption <mark_weaver>so, for example, if you multiply two signed positive integers A*B=C and check for overflow by checking if C/B=A, modern C compilers will literally remove that check as dead code. <mark_weaver>unsigned arithmetic is different. it's allowed, and has guaranteed portable semantics. <b4284>i mean, one can also learn about C in this channel :) <mark_weaver>b4284: if you're comfortable sharing, I'm curious to hear why you want these fixed-width operations. it might help be better point you in the right direction. <mark_weaver>(and if it's just for learning or playing, that's fine too :) <b4284>yeah, it's pretty much just playing with it <b4284>because i work with C, so i have to deal with signedness and endianness a lot <sprang>I was wondering if there is a standard scheme function that does something like this? <sprang>(define (use-if test value) (if (test value) value #f)) <sprang>mark_weaver: ok, thanks. suggested rewrite is elegant <uu_>hi, can I use guile in C++ projects? will it link correctly with c++ runtime? ***lloda` is now known as lloda
<uu_>guile currently does not seem to have rich libraries <uu_>I am a little worried about adding it to my project <uu_>compared with lua/ python <uu_>could you give me some advice? <amz3>what is your library uu_ <nalaginrut>uu_: IMO, at present, for client side, python maybe better, unless you are not in a pressure to done the work, you may try guile <nalaginrut>I confess I incline to python in client side when I do some not-for-fun work <nalaginrut>uu_: I do so because I want to save my time for better hacking <nalaginrut>uu_: but if you want to try some cool ideas, I would recommend use Guile as possible <nalaginrut>use python do the boring work, when I pick up Guile, I want to be cool <uu_>nalaginrut: thanks for your advice. guile seems easier to integrate compared with python <nalaginrut>uu_: yes, it's good for embedding into c/c++ programe <nalaginrut>of course, a better framework based on FFI is better, but it's enough for the work <uu_>FFI -- its name! I used it but I didnot know its name <uu_>for python, I hope there could be something like ctypes for c++ <ArneBab>uu_: what functionality do you need? <uu_>I once exported some api after warping my c++ func. to c <ArneBab>(compared to Python or Java everything has few libraries at the moment…) <uu_>ArneBab: currently I have written up a somewhat complex "system", and it accepts some input and some configurations. Now I want to play with different inputs and configurations. <ArneBab>do you need access to stuff like netcdf data files or specific online-services (for which Python libraries exist)? <ArneBab>uu_: do you want to ship the system to users? <uu_>currently the system works by loading a input file and a configuration file, which makes it hard to play <uu_>it is amazing. and it seems it could save me a script extension system <uu_>ArneBab: it is a research project <uu_>the final user is me and my collegues <ArneBab>that’s already a good situation for using Guile :) <ArneBab>so you’d build a shell or a commandline application? <uu_>haha. yeah, I will try it <ArneBab>if the input files are large, an interactive shell might be better: only load each file once and then try different configurations <ArneBab>it sounds like you won’t really need lots of libraries <ArneBab>but the ability to improve the scripting language with macros could save you lots of hassle <ArneBab>I used Python for my plotting framework and in the end designed extensive commandline control with lots of caching to make it usable. <amz3>uu_: there is framework for C++ it's built by pypy, I don't recall the name <amz3>I agree with nalaginrut, I wish I did more guile :/ <wleslie>the 'plugins' on the website mock-up reminds me of vihart's "the bowl and the lazer bat" <amz3>I have a the feeling that it's too child-ish <amz3>I like it but, maybe it's doesn't look serious enough <healer>Just wondering if guile will not be a perfect candidate language for this sort of thing <civodul>GuixSD still uses Linux-libre as its device driver; Interim looks like the next step ;-) <healer>civodul: Yeah, the way guile is structured and tightly integrated into C, methinks implementing this will be a no-brainer to guile-hackers out there <uu_>amz3: you mean cppyy, it looks like it depends on cling (ROOT) <healer>for educational purposes at least <davexunit>I see that the guildhall github account forked my old guile-zlib repo <taylanub>does anyone know what struct packing and alignment configurations are useful to implement in an FFI system? so far I support decreasing padding (like '#pragma pack(n)'), but not increasing it (like '__attribute__ ((aligned (n)))'). is the latter worth supporting? do C libraries with a stable ABI ever use it? <civodul>davexunit: didn't know you had worked on that <civodul>it's going to be useful to 'guix publish'! <davexunit>will it be useful there? I thought we need bzip2 compression? <civodul>i'd bet it can support libbz2 for maybe 10 additional lines of code <ahmedtd_>taylanub: If it exists, a C library has used it <ahmedtd_>I mean, even guile is a C library, "technically" <ahmedtd_>A better question is whether you should worry about it <ahmedtd_>But increased alignment is sometimes used when you want to force structs to lie along cache or page lines ***dje is now known as xdje
<paroneayea>ACTION learns the (cond ((8 => (lambda (x) (+ x 2))))) syntax <rekado>do you know if anyone is currently working on speeding up Guile Emacs? Is this a general Guile compilation problem or is it specific to Guile's elisp support? <paroneayea>rekado: the last time I talked to bipt they said there were known ways they could optimize things <paroneayea>I don't know what their schedule is like... at the time they were optimistic they would have time to work on it, but we all know how life things can go <paroneayea>I'm very interested in seeing guile-emacs succeed <paroneayea>maybe over time I'll become knowledgeable enough to help in some smaller way <rekado>I'd *love* to use Guile Emacs. The more Guile the better. <daviid>what is the traditional/recommended autool location where to install examples ?