RE: extended foreign decls

2001-01-03 Thread Alastair Reid
> > > I refrained from proposing this in an earlier mail, but I've been > > > thinking about it for a long time. I *really* *really* want to be > > > able to insert small snippets of foreign code into the source of > > > a Haskell module. I *really* *really* don't want this. The current Hugs im

RE: freeHaskellFunctionPtr

2001-01-03 Thread Alastair Reid
> > I would let freeHaskellFunPtr accept and ignore nullFunPtr, since I > > once had to write > > when (ptr /= nullFunPtr) $ freeHaskellFunPtr ptr > > and it can be seen as consistent with free. This sort of behaviour is comon in C but I think this is mostly because C has such a weak type sys

RE: Typing f.e.d.

2001-02-12 Thread Alastair Reid
> Yes, Addr is dead. So, allowing Addr in f.e.d., or anywhere > else for that matter, can only be for reasons of temporary > backward compatibility. Please note that this temporary backward compatability happens to be an important part of most ffi code currently in existence (at least, all the c

RE: Modification to foreign import/export

2001-02-12 Thread Alastair Reid
use a C++ programmer could use the exports from the Java library too), is simpler, is more flexible, ... Could someone summarise the minus side for me? I think I missed the motivation for extending the ffi to support other languages. -- Alastair Reid ps Could I propose that any proposed new

RE: Modification to foreign import/export

2001-02-12 Thread Alastair Reid
re not keywords in any context except foreign language > declaration. That's why I wrote "pseudokeywords". I hope you don't mean anything like Haskell 98's "as", "qualified" and "hiding" special identifiers? Those have to be one of the worst feature

RE: Typing f.e.d.

2001-02-12 Thread Alastair Reid
> Alastair Reid wrote: > > [...] ps I have a feeling of feeping creaturism as I watch this list - > > a nice simple design seems to be getting more complex. > > Could you elaborate on this? The basic FFI *is* still nice and simple > IMHO. I'm thinking of: 1) Trying

RE: Modification to foreign import/export

2001-02-21 Thread Alastair Reid
> "Alastair Reid" <[EMAIL PROTECTED]> wrote, > > > Marcin wrote: > > > This has the advantage that when the library name is #ifdefed, the > > > conditional needs not to be repeated for each function. Similarly > > > for #included header names

RE: Summary of current change suggestions

2001-02-21 Thread Alastair Reid
> So, as Marcin pointed out, the only use for a library object > spec for ccall is so that interpreters know which handle to > pass to dlsym(). This may be the only use but I think it's a very important use. > I am not too fond of the idea that the interpreter has to try > a dlsym() on all libra

RE: Summary of current change suggestions

2001-02-21 Thread Alastair Reid
>* specifying libraries in the source isn't the right way to > go. Library names change independently of APIs, and can be > platform-specific. I like the high level goal this is heading towards and was in complete agreement with implementing it in rules like this until I real

RE: Summary of current change suggestions

2001-02-21 Thread Alastair Reid
The first time I read this syntax, I misinterpreted it. I think my misinterpretation might be interesting so I'll give it below in case anyone else likes it. > foreign library C"" "-lcurses" > foreign library java "blah" "blah" > > foreign import C"curses_function" cf ::

RE: Summary of current change suggestions

2001-02-22 Thread Alastair Reid
> Marcin just pointed out that you can use dlopen() in a way > that it finds symbols without a library name. That should > do, I think. Note that finding a marginally easier way to do the lookup doesn't address my concern that this undirected search will cause maintenance and porting problems by

cpp

2001-02-22 Thread Alastair Reid
While on the subject of preprocessors, I thought I'd mention a need I've found in distributing tools like Knit where the intended audience isn't expected to: 1) Care either way about it being implemented in Haskell 2) Have any desire to spend half a day installing lots of Haskell-related tools

RE: cpp

2001-02-22 Thread Alastair Reid
> hsc2hs is in ghc-4.11. Did I miss the last 3 releases? I'm still stuck with something between 4.08.1 and 4.08.2 waiting for a debian package and freebsd port to appear for 4.08.2. :-) [Serious content of which is that I'm absolutely _not_ interested in subjecting users of my tools to the blee

RE: cpp

2001-02-23 Thread Alastair Reid
join the knit-users or knit-announce mailing lists, send email to [EMAIL PROTECTED] with, e.g, "subscribe knit-users" in the body. Thanks go to DARPA for their support, and thanks go to the entire Knit crew below, but especially Alastair Reid, for the fine research, development, and hard work t

RE: Modified proposal for default decls

2001-02-26 Thread Alastair Reid
> Many C interfaces contain a significant number of macros. And C is > one of the most widely used languages that we want to interface with. > So it seems to me that any FFI which aims to provide *good* support for > C ought to provide a way of accessing C macros. Since an explicit goal of the o

RE: Modified proposal for default decls

2001-02-26 Thread Alastair Reid
> Many C interfaces contain a significant number of macros. And C is > one of the most widely used languages that we want to interface with. > So it seems to me that any FFI which aims to provide *good* support for > C ought to provide a way of accessing C macros. [Sorry for replying twice to th

RE: unsafePerformIO and unsafeInterleaveIO

2001-03-19 Thread Alastair Reid
> Should these functions be available through the standard FFI? > IMHO they should. I don't understand the question. Are you asking which modules should export them? Alastair ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listin

RE: unsafePerformIO and unsafeInterleaveIO

2001-03-21 Thread Alastair Reid
> Without a standard way to get > at unsafePerformIO, such code would still rely on > non-standard features, which goers against the aim of > standardising the rest of the FFI. The Hugs-GHC standard libs have them exported from IOExts. Of course, the Hugs-GHC standard isn't an official Haskell l

RE: unsafePerformIO and unsafeInterleaveIO

2001-03-21 Thread Alastair Reid
> Sadly, due to lack of support on the Hugs side, the Hugs/GHC extension > libraries have drifted apart. Sadly true. But any parts of the standard that haven't changed in the last 2.5 years (e.g., unsafe{Perform,Interleave}IO) still work - so in this case it can be relied upon. Alastair ps I

RE: unsafePerformIO and unsafeInterleaveIO

2001-03-22 Thread Alastair Reid
> Alastair: > > The Hugs-GHC standard libs have them exported from IOExts. Manuel: > There is only one flaw: It doesn't work with nhc98. Huh? I thought nhc provided a reasonable subset of the Hugs-GHC libraries and, since the IO extensions are one of the first extensions people ask for, I assu

RE: FFI progress

2001-03-28 Thread Alastair Reid
I like this nice, simple design. I'm a little uncertain about the multiple header-file aspect but have no strong feelings either way. If most libraries could be ffi'd without the need for additional C files, the multiple header file notation would be an obvious win. As it is, many libraries I

RE: FFI progress

2001-04-06 Thread Alastair Reid
> Is anyone actually specifying > > stdcall > ccall > > calling conventions in a foreign import? hslibs/win32/Win32Dialogue.gc uses stdcall. cvs annotate says that this was written by Sigbjorn in October 1999. I'm not sure whether anyone depends on this. (The HGL definitely does

RE: Revised FFI syntax + typing

2001-05-03 Thread Alastair Reid
> Why is Word a GHC extension? Someone remind me? It's not part of the Hugs-GHC standard which is what we were working to when the ffi first came out. It's not part of that standard because it was felt at the time that bounded types with ill-defined ranges were a portability problem waiting to

RE: Revised FFI syntax + typing

2001-05-03 Thread Alastair Reid
> I don't agree that having a type of a fixed but unspecified size is evil. > You can query the sise - you don't have to assume any particular size - > and you have explicitly sized types as well. I suspect we're never going to agree about this but perhaps we can try to understand why the other f

Re: FFI Definition

2001-05-06 Thread Alastair Reid
But it is also used for exporting so the name doesn't seem that inappropriate. Unless you're arguing that, since it brings a name into scope it can be thought of as a kind of import??? (But I don't think you are saying that.) -- Alastair Reid

RE: Revised FFI syntax + typing

2001-05-06 Thread Alastair Reid
ed. The H98 Committee in their infinite wisdom chose to > have types with system-dependent sizes and I think, we should be as > orthogonal as possible whether we like it or not. But H98 doesn't have Word so I don't see a requirement to add it or to provide ffi support for it.

extent strings

2001-05-14 Thread Alastair Reid
By this, I mean, two logically separate grammars (as in the current proposed syntax) instead of two physically separated grammar (as, for example, if someone were to provide a grammar for the C++ ffi binding as appendix G to the report). Is anyone else concerned

Re: Haskell FFI 1.0 vs Haskell/Direct: influence? loss of abstraction level?

2002-04-25 Thread Alastair Reid
macros :-) > Feature Request: Searchable archives at haskell.org/pipermail :) That would be nice, wouldn't it. (Hmmm, I think you can tell google to restrict its search to a particular site - so maybe we could just use google.) Hope this helps, -- Alastair Reid _

Re: Problem with FFI?

2002-06-02 Thread Alastair Reid
emented in > haskell which an app wishes to link against. You can implement the modified API (or your modified semantics) quite readily as a little library which you link against your program. All you have to do is tweak the names a little (e.g., s/hs/HS/) to avoid name clash

Minor tweaks to ffi addendum

2002-06-02 Thread Alastair Reid
was almost all done ages ago). That leaves the question of whether we want to force Haskell implementations to follow C conventions. I'm not sure. Table 3 (section 6): Proposed change: Rename column 1 as 'Preprocessor symbol

Re: Minor tweaks to ffi addendum

2002-06-03 Thread Alastair Reid
might quickly use up a lot of memory - and in all that time you don't go anywhere near the IO monad. -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: Minor tweaks to ffi addendum

2002-06-03 Thread Alastair Reid
flag in the foreign export wrapper code. We could imagine getting the Haskell typesystem to check that newForeignPtr' is only used with unsafe free functions. It'd be a bit verbose but we could probably do it. There's not much point though since C can't do a similar job on its

Re: Minor tweaks to ffi addendum

2002-06-03 Thread Alastair Reid
it is a greater burden it is not a new burden unlike any they normally deal with. 3) If they're using GHC, they are free to specify that their imported finalizer is 'safe' (or threadsafe) and that 'safe' finalizer can happily call

Re: Minor tweaks to ffi addendum

2002-06-05 Thread Alastair Reid
t; right thing - you really want to do the allocation/deallocation > explicitly in the IO monad. Those kinds of applications exist - but there are many pure programs for which ForeignPtrs work extremely well and for which it would be painful to have to insert frequent calls to 'runFinali

Re: How do you represent a C pointer type?

2002-06-07 Thread Alastair Reid
se_Me Int type DBP = Ptr DB or newtype DB = DB_Dont_Use_Me Int foreign import ... :: blah -> IO (Ptr DB) the idea being that no-one would ever use the data constructor or the Int. I'm a bit puzzled by the double-layer of pointers though. -- Alastair Reid[EMAIL PROTEC

Re: More on Ptr types

2002-06-07 Thread Alastair Reid
o for a while (or, in less anthropomorphic language, it is an opaque/abstract datatype). -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: More on Ptr types

2002-06-11 Thread Alastair Reid
there would be non-standard extensions which let C programmers override the default alignment of a type.) -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

deRefStablePtr exception?

2002-06-11 Thread Alastair Reid
What exception does deRefStablePtr raise when handed an invalid pointer such as 0? -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: More on Ptr types

2002-06-11 Thread Alastair Reid
er > information. Ok, if they're passed the same way and all we have to do is respect the bottom bits, that's easy. Don't use the cast functions provided by the Foreign libraries and all will be cool. (We might want to do an audit of the libraries to determine which other func

Re: deRefStablePtr exception?

2002-06-12 Thread Alastair Reid
inter. Which brings me back to my question: _which_ exception should it raise? -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

exporting functions which raise exceptions

2002-06-12 Thread Alastair Reid
ng to do seems to be to return to the interpreters REPL. -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

hs_garbage_collect

2002-06-12 Thread Alastair Reid
if (next_depth == 0) { minor_garbage_collect(); next_depth = 1; return 1; } else { major_garbage_collect(); next_depth = 0; return (pending_finalizers > 0); } } -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ps

Re: exporting functions which raise exceptions

2002-06-12 Thread Alastair Reid
ts rather than doing it a bit at a time and getting bits wrong because I lack a complete enough picture.) -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: deRefStablePtr exception?

2002-06-13 Thread Alastair Reid
been freed then they should return nullPtr? If so, is this required or just hinted/recommended? > Either 'ErrorCall "Foreign.StablePtr.deRefStablePtr: invalid stable > pointer"', or a new exception. I don't mind which. I'll pick one and add my choice to t

Re: exporting functions which raise exceptions

2002-06-13 Thread Alastair Reid
f concurrency) it is hard to define > what exactly is supposed to happen with such exceptions. I'm not sure I see the difficulty - but I'll go ahead and make up my own solution (which will probably be much like what GreenCard does...) --

Re: exporting functions which raise exceptions

2002-06-14 Thread Alastair Reid
e I understand what would cause that failure), it calls exit. A bit more error reporting seems to be called for here... -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Library archives

2002-06-14 Thread Alastair Reid
is that anything legal on a link line is ok (so all the above are kosher) but it may be sensible to limit it to just the first 3 forms. I'd like the spec to say what's legal and give at least one example. -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ __

Re: Library archives

2002-06-16 Thread Alastair Reid
and with Hugs comment on whether they'd be able to replace the ffi's library spec and would make sense for typical Hugs usage. And would that meet SimonPJ's need too? -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ps The reason I'm wary

Re: Library archives

2002-06-18 Thread Alastair Reid
space and then any dynamically loaded code or foreign imports would do lookups in these files. [Actually, Hugs probably would not use --lib= because Hugs traditionally uses cryptic, confusing flag names...] -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/

Re: freeHaskellFunPtr

2002-06-18 Thread Alastair Reid
Sven: > In a nutshell: I'm not very happy with the explicit allocation and > deallocation of the 'foreign import wrapper' thunks. They are an > artefact of the Haskell implementations and look strange in an > otherwise GC-ed world... I think they're explicitly deallocated (and, hence, explicitly

Re: Library archives

2002-06-18 Thread Alastair Reid
ing dlopen). 2) It is useful for .net - though I didn't hear why this was supposed to be relevant to people calling C. I'd like answers to these questions that are clear enough that we can agree on them and amend the spec to be clear. -- Alastair Reid[EMAIL PROTECTED]

Re: Problem with FFI?

2002-06-21 Thread Alastair Reid
John Meacham <[EMAIL PROTECTED]>: > however i would make one change, only the first > calls to hs_set_hs_argv and hs_set_prog_argv are honored, after that > they are ignored, that way if multiple libraries wish to set the > arguments it wont run into undefined behavior. (since there is no > way i

Re: Getting constants from #defines

2002-06-26 Thread Alastair Reid
ble to implement the ffi by dlopening a bunch of .o, .a and .so files and looking up symbols in them - with no C compiler anywhere in the picture. IIRC, this is how ghci worked at one stage - not sure if it still does. -- Alastair Reid [EMAIL PROTECTED]

Re: More C interfacing issues

2002-07-02 Thread Alastair Reid
deref r 1 free r return (y,x) or guess/check that getyx is really, really cheap to call and write two wrappers gety and getx. -- Alastair Reid [EMAIL PROTECTED] http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: More C interfacing issues

2002-07-02 Thread Alastair Reid
hey do. It's a shame C doesn't support multiple return values and kinda surprising given that C is like assembler in so many other ways. -- Alastair Reid [EMAIL PROTECTED] http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI ma

Re: More C interfacing issues

2002-07-03 Thread Alastair Reid
> :: Ptr Window -> Ptr CInt -> Ptr CInt -> IO () > Have I missed something? You need at least one wrapper because getyx is a macro. Note that the arguments are ints _not_ int*s. -- Alastair Reid [EMAIL PROTECTED] http://www.reid-consulting-uk.ltd.uk/alastair/ __

Re: More C interfacing issues

2002-07-03 Thread Alastair Reid
s)) if you omit the %call line. Roughly speaking, you use %call lines in the same places that you'd introduce a wrapper in greencard. So you don't tell it that it's a macro but you do write a %call line and the code in the %call line will reflect the fact that you know it is a macr

Re: Generating Function Prototypes

2002-07-03 Thread Alastair Reid
not they add prototypes. GHC: yes, NHC: no, Hugs: depends which day you grabbed your copy from CVS. (I'm not sure that the ffi should allow compilers to vary in this way but it does.) -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___

Re: Generating Function Prototypes

2002-07-03 Thread Alastair Reid
ties is found to change, I believe we would change the ffi so that it is still feasible to generate correct machine code without being given a function prototype by the user.) Of course, this ignores the detail that while the C compilers are generating correct code, they may also be generating warn

Re: Generating Function Prototypes

2002-07-03 Thread Alastair Reid
>> Of course, this ignores the detail that while the C compilers are >> generating correct code, they may also be generating warnings about >> alleged type errors - which can be a bit disconcerting. > It is an error, not just a warning, if the prototypes don't match. > GCC will complain loudly i

Re: Generating Function Prototypes

2002-07-04 Thread Alastair Reid
Alastair: >> (I'm not sure that the ffi should allow compilers to vary in this >> way but it does.) Manuel: > The FFI doesn't really allow compilers to emit prototypes (at least > not in general) as this leads to semantic differences eg in argument > promotion, for which Section 4.1.5 precisely

Re: Generating Function Prototypes

2002-07-04 Thread Alastair Reid
Alastair: >> Well, if you disable the warning by giving gcc a consistent story, >> then the code is correct. (To give gcc a consistent story, don't >> #include any user or system-supplied headers and make sure gcc >> doesn't silently #include any of its own (as it likes to do).) Simon: > I don'

Re: Generating Function Prototypes

2002-07-04 Thread Alastair Reid
> Errm, shouldn't that be: [...] > Or is there some other trick involved here? Sorry, yes it should - just me getting confused in translating between Haskell's f :: A -> B and C's B f(A); A ___ FFI mailing list [EMAIL PROTECTED] http://www.hask

Re: Generating Function Prototypes

2002-07-07 Thread Alastair Reid
combinations to worry about if the ffi is not portable but only n combinations to worry about if the ffi is portable between compilers. -- Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/ ___ FFI mail

Re: Generating Function Prototypes

2002-07-08 Thread Alastair Reid
Minor detail: > typedef long long HsInt64; Instead of writing your own definition, you can #include HsFFI.h -- Alastair ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: Generating Function Prototypes

2002-07-08 Thread Alastair Reid
> Sure, it's a problem, a bug in GHC, whatever. But I don't see a way > around it! Make the spec say that you have to have header files containing prototypes to get correct results. It is not ideal but it is something that can be readily implemented by all Haskell compilers so we can get por

Re: Generating Function Prototypes

2002-07-08 Thread Alastair Reid
> [...] if we were somehow able to generate prototypes then there > would be no type checking at all. Here's 4 ways to get typechecking - all admittedly harder than relying on the fact that your Haskell compiler invokes a C compiler as part of its operation (as does Hugs - not trying to put GHC

Proposed change to ForeignPtr

2002-08-08 Thread Alastair Reid
;ll take a bit longer to add that functionality and we can compile most (all?) of the hierarchial libs without it. -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI ma

Re: Proposed change to ForeignPtr

2002-08-09 Thread Alastair Reid
rom the standards point of view, I am > actually *very* reluctant to introduce new names. On the other > hand, reusing the old names will lead to a couple of unhappy emails > from people using the old interface again. But only a couple I conjecture. -- Alastair Reid [EMAI

Updates to FFI spec

2002-08-09 Thread Alastair Reid
http://www.mail-archive.com/ffi@haskell.org/msg00539.html -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: Proposed change to ForeignPtr

2002-08-09 Thread Alastair Reid
write: > foreign import "&" free :: FunPtr (Ptr CChar -> IO ()) > > foo = do > ... > foreignPtr <- newForeignPtr cString free > ... All the rest of your code to manipulate ForeignPtrs remains the same. (Well, there's a corresponding change in addForeignFinaliz

Re: Proposed change to ForeignPtr

2002-08-11 Thread Alastair Reid
functions) and finding new names for the old functions (the ones with closure arguments). -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: Updates to FFI spec

2002-08-11 Thread Alastair Reid
. Currently, there is a problem with the version > that is in the spec and GHC in that GHC requires an extra argument > to initialise modules. So, it all depends a bit on how far SimonM > thinks its implementable. Hugs doesn't have anything resembling hs_init at the moment so I can

Re: Updates to FFI spec

2002-08-12 Thread Alastair Reid
> System.Mem.performGC does a major GC. When would a partial GC be > enough? I've described the image-processing example a bunch of times. We have an external resource (e.g., memory used to store images) which is somewhat abundant and cheap but not completely free (e.g., eventually you start t

Re: Library archives

2002-08-12 Thread Alastair Reid
> Under .NET each DLL has its own namespace, so the [lib] spec is > needed to disambiguate. Since it's a namespace issue, I'd feel > better if on .NET the name of the C function took a different form > (perhaps .) and [lib] is removed from the spec. Isn't that just a different syntax for the sa

Re: Updates to FFI spec

2002-08-13 Thread Alastair Reid
> Hmmm, the garbage collector is a black box and has its own > complicated heuristics for managing memory usage, but you are > describing a mechanism that depends rather heavily on certain > assumed behaviours. At the least, that gives the garbage collector > less flexibility to change its own b

Re: Updates to FFI spec

2002-08-13 Thread Alastair Reid
> At the moment, there are two kinds of initialisation done for each > module: Both ELF and DLLs on Windows provide a way of specifying initializers. Or, easier yet, since the user is already using the hs_init function, you could use that. The way you'd do that in ELF is to define a special se

Re: Cheap ForeignPtr allocation

2002-09-02 Thread Alastair Reid
Can you achieve the same performance gain by adding some rewrite rules? -- Alastair ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Proposed change to ForeignPtr

2002-09-03 Thread Alastair Reid
wForeignPtr and addForeignPtrFinalizer [GHC can go ahead and list them as non-standard extensions] There's a minor issue about whether the old function names should be reused (leaving GHC to come up with its own names) or not. I have ceased to care either way. -- Alastair Reid

Re: Cheap ForeignPtr allocation

2002-09-03 Thread Alastair Reid
ier (as the withFoo functions do) or raised the level of abstraction. I'm inclined to say: add it to GHC for now and prod us again once a decent body of examples builds up. -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http

Re: Cheap ForeignPtr allocation

2002-09-04 Thread Alastair Reid
> Nevertheless, I think even without the tricks I'm using in GHC, the > case where a ForeignPtr is used in conjunction with malloc()/free() > is one which is likely to be optimisable in any system with its own > memory management. I wasn't meaning so much that only GHC could take advantage of it

Re: Proposed change to ForeignPtr

2002-09-05 Thread Alastair Reid
> I thought we have settled this already. See my appended email from > three weeks ago. The only reason I haven't changed it in the spec > yet is that I wanted to give people time to object. Nobody has. > So, I would deem this accepted (reusing the old function names btw). Sorry, yes you had.

Re: module Data.Bits

2002-09-09 Thread Alastair Reid
> The FFI spec says that the operations called 'shift' and 'rotate', > shift and rotate their argument to the right. However, the GHC > implementation in CVS shifts and rotates to the left, and is > documented to do so. > Who is right? FWIW, before I read any documentation I expected the > und

Re: module Data.Bits

2002-09-10 Thread Alastair Reid
> Alastair: it was your design originally I believe, any thoughts? Actually, I think it was Lennart's - though he might disown our variant... The change seems fine. (Actually, it feels a bit like another instance of defining the language to allow particular optimizations in particular tech

Re: Updates to FFI spec: hs_init() & friends

2002-09-10 Thread Alastair Reid
> So, my proposal is to: > [...] Another possibility is to say that we don't really understand the issues well enough to put in the standard yet and just comment out that section. I think only GHC implements anything like this (correct me if wrong, Malcolm) and they haven't used it in the way J

Re: Updates to FFI spec: performGC

2002-09-10 Thread Alastair Reid
I think the thing to do is add the existing performGC to the standard (perhaps giving it an hs_ prefix in the process) and leave development of an extended version of the function for when the GHC folk (or anyone else with a generational collector) decide they want a forcefulness argument. Come

Re: Proposed change to ForeignPtr

2002-09-10 Thread Alastair Reid
> I have changed this in the spec now. I attach the wording used in > the spec. Looks good. A ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: module Data.Bits

2002-09-10 Thread Alastair Reid
> Errm, but in C there is no unified shift operator. You have << for > left shift and and >> for right shift, and a negative shift is > undefined. [blush] >> This makes the specification come out nice and clean - you're >> multiplying the number by 2^n instead of 2^{-n}. > Errm, but then righ

Re: Proposed change to ForeignPtr

2002-09-10 Thread Alastair Reid
(i.e., the type the external library provides) instead of hs_stablePtr_t. In particular, if I put a wrapper around an object so that I can attach a reference counter, you somehow always find yourself faced with the problem that a C library hands you a pointer to an unwrapped object and you h

Re: module Data.Bits

2002-09-10 Thread Alastair Reid
> Another conflict between the FFI spec and the current library > implementation: the spec says > "The function bitSize returns 0 for types that don't have a > fixed bitsize (e.g. Integer)." > whereas the current ghc implementation defines bitSize of Integer as > a runtime error. I think b

Re: Proposed change to ForeignPtr

2002-09-10 Thread Alastair Reid
ptive concurrency so it's no wonder that the ffi extension doesn't address them. We could start working on a concurrency extension but that's a different beast. That said, we probably do need a few hooks to make Haskell talk to other GCs better. See the paper I pointed at this aft

Re: Proposed change to ForeignPtr

2002-09-10 Thread Alastair Reid
limited ways). > If it's really impossible for NHC or Hugs to implement this, I think > I would still rather it was left to the NHC and Hugs documentation > to admit that exported Haskell functions basically don't work in > some circumstances, rather than to the GHC doc

Re: Proposed change to ForeignPtr

2002-09-11 Thread Alastair Reid
GCs to run simultaneously. Just thinking aloud, I wonder if it would be any easier to implement? The communication would be much the same ('I'm starting', 'I can reach X' and 'I'm done') but there'd be no need to synchronize the GCs. -- Alastair Reid

Re: Updates to FFI spec: performGC

2002-09-11 Thread Alastair Reid
ecify that in a non-operational (i.e., implementation dependent) way. We could insert the word 'full' and leave it to people's imaginations? -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ _

Re: Updates to FFI spec: performGC

2002-09-11 Thread Alastair Reid
(using a finer-grained interface) if we didn't provide it for them - only those who have real time programs interfacing to Haskell would make use of the finer-grained interface. -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: Updates to FFI spec

2002-09-13 Thread Alastair Reid
Alastair: >> (In the image processing example, images were megabytes and an >> expression like (x + (y * mask)) would generate 2 intermediate >> images (several megabytes) while doing just 2 reductions in >> Haskell.) Marcin: > OCaml allows the programmer to specify an approximate amount of > fo

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 7

2002-09-18 Thread Alastair Reid
> RC 7 of the FFI Addendum is now available from In adding mallocForeignPtr and friends to Hugs, I found that I needed the address of free to pass as a parameter. There's no suitable way to generate &free from MarshalAlloc.free (the obvious use of a Haskell wrapper would break the whole reason

Re: lightweight struct handling in FFI?

2002-09-19 Thread Alastair Reid
ut more than just copying a small object over. -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ ___ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 7

2002-09-19 Thread Alastair Reid
> ... maybe I'm being stupid, but I don't see what the problem is. > Why can't mallocForeignPtr be implemented as: > mallocForeignPtrBytes size = do > r <- c_malloc (fromIntegral size) > newForeignPtr r ptr_c_free > > foreign import ccall unsafe "malloc" > c_malloc :: CInt -> Pt

Re: addForeignPtrFinalizer

2002-09-24 Thread Alastair Reid
> The spec says there are no guarantees on the order in which the > finalizers are run. Doesn't this make this function almost > impossible to use? Suppose one finalizer frees the storage and the > other cleans up something it refers to. I seem to remember that Sigbjorn and Erik dealt with thi

  1   2   3   >