Search Results

Search found 37 results on 2 pages for 'rwallace'.

Page 2/2 | < Previous Page | 1 2 

  • F# mutual recursion between modules

    - by rwallace
    For recursion in F#, existing documentation is clear about how to do it in the special case where it's just one function calling itself, or a group of physically adjacent functions calling each other. But in the general case where a group of functions in different modules need to call each other, how do you do it?

    Read the article

  • F# powerpack and distribution

    - by rwallace
    I need arbitrary precision rational numbers, which I'm given to understand are available in the F# powerpack. My question is about the mechanics of distribution; my program needs to be able to compile and run both on Windows/.Net and Linux/Mono at least, since I have potential users on both platforms. As I understand it, the best procedure is: Download the powerpack .zip, not the installer. Copy the DLL into my program directory. Copy the accompanying license file into my program directory, to make sure everything is above board. Declare references and go ahead and use the functions I need. Ship the above files along with my source and binary, and since the DLL uses byte code, it will work fine on any platform. Is this the correct procedure? Am I missing anything?

    Read the article

  • C# expression tree for ordinary code

    - by rwallace
    It's possible to create an expression tree, if you declare it as such. But is it possible to get an expression tree for an ordinary chunk of code such as a method or property getter? What I'm trying to do is, let's say for an order processing system, I have a class for order items: class Item : Entity { [Cascade] public Document document { get; set; } public int line { get; set; } public Product product { get; set; } public string description { get; set; } public decimal qty { get; set; } public decimal price { get; set; } public decimal net { get { return qty * price; } } public VatCode vat_code { get; set; } } where the net value equals qty * price, so I'd like to declare it as such, either with a property or method, and then also have the framework introspect that expression so it can generate appropriate SQL for defining a corresponding calculated column in a corresponding database view. The most obvious way to do this would be to get the expression tree for a property getter or a method, but I can't find any indication how to do this, or that it is possible. (I have found a way to get a method body as a byte stream, but that's not what's desired here.) If that isn't possible, I suppose the recommended solution would be to declare something like a static field that is an expression tree, and compile/run it at run time for internal use, and also introspect as normal for SQL generation?

    Read the article

  • Better language or checking tool?

    - by rwallace
    This is primarily aimed at programmers who use unmanaged languages like C and C++ in preference to managed languages, forgoing some forms of error checking to obtain benefits like the ability to work in extremely resource constrained systems or the last increment of performance, though I would also be interested in answers from those who use managed languages. Which of the following would be of most value? A language that would optionally compile to CLR byte code or to machine code via C, and would provide things like optional array bounds checking, more support for memory management in environments where you can't use garbage collection, and faster compile times than typical C++ projects. (Think e.g. Ada or Eiffel with Python syntax.) A tool that would take existing C code and perform static analysis to look for things like potential null pointer dereferences and array overflows. (Think e.g. an open source equivalent to Coverity.) Something else I haven't thought of. Or put another way, when you're using C family languages, is the top of your wish list more expressiveness, better error checking or something else? The reason I'm asking is that I have a design and prototype parser for #1, and an outline design for #2, and I'm wondering which would be the better use of resources to work on after my current project is up and running; but I think the answers may be useful for other tools programmers also. (As usual with questions of this nature, if the answer you would give is already there, please upvote it.)

    Read the article

  • F# ref-mutable vars vs object fields

    - by rwallace
    I'm writing a parser in F#, and it needs to be as fast as possible (I'm hoping to parse a 100 MB file in less than a minute). As normal, it uses mutable variables to store the next available character and the next available token (i.e. both the lexer and the parser proper use one unit of lookahead). My current partial implementation uses local variables for these. Since closure variables can't be mutable (anyone know the reason for this?) I've declared them as ref: let rec read file includepath = let c = ref ' ' let k = ref NONE let sb = new StringBuilder() use stream = File.OpenText file let readc() = c := stream.Read() |> char // etc I assume this has some overhead (not much, I know, but I'm trying for maximum speed here), and it's a little inelegant. The most obvious alternative would be to create a parser class object and have the mutable variables be fields in it. Does anyone know which is likely to be faster? Is there any consensus on which is considered better/more idiomatic style? Is there another option I'm missing?

    Read the article

  • HTML img scaling

    - by rwallace
    I'm trying to display some large images with HTML img tags. At the moment they go off the edge of the screen; how can I scale them to stay within the browser window? Or in the likely event that this is not possible, is it possible to at least say "display this image at 50% of its normal width and height"? The width and height attributes distort the image -- as far as I can tell, this is because they refer to whatever attributes the container may end up with, which will be unrelated to the image. I can't specify pixels because I have to deal with a large collection of images each with a different pixel size. Max-width doesn't work.

    Read the article

  • Postgres turn on log_statement programmatically

    - by rwallace
    I want to turn on logging of all SQL statements that modify the database. I could get that on my own machine by setting the log_statement flag in the configuration file, but it needs to be enabled on the user's machine. How do you enable it from program code? (I'm using Python with psycopg2 if it matters.)

    Read the article

  • End marker for command line arguments

    - by rwallace
    I'm writing a program which takes filenames and options on the command line in the usual way, and also can be directed to read arguments from a file. I'm implementing the semi-standard -- to turn off special treatment of subsequent arguments, and # as comment marker. I also want to implement a marker for 'disregard all arguments from here on', i.e. an end marker. Is there a common/semi-standard way to indicate this? Or, what way would people find least surprising?

    Read the article

  • F# match char values

    - by rwallace
    I'm trying to match an integer expression against character literals, and the compiler complains about type mismatch. let rec read file includepath = let ch = ref 0 let token = ref 0 use stream = File.OpenText file let readch() = ch := stream.Read() let lex() = match !ch with | '!' -> readch() | _ -> token := !ch ch has to be an int because that's what stream.Read returns in order to use -1 as end of file marker. If I replace '!' with int '!' it still doesn't work. What's the best way to do this?

    Read the article

  • C# equivalent of typeof for fields

    - by rwallace
    With reflection, you can look up a class from a string at run time, but you can also say typeof(Foo) and get compile time type checking, auto completion etc. If what you want is a field not a class, you can look it up from a string at runtime, but if you want compile time type checking etc., is there anyway to say something like fieldof(Foo.Bar)? I know the name of both the class and the field in advance, and I want to be able to refer to the field at compile time rather than with a run-time string lookup.

    Read the article

  • Java FileDialog programmatically set size

    - by rwallace
    I want to display a Java FileDialog and sets its initial size to something reasonable (it doesn't show the maximize button, and a lot of users might not know you can use alt-space X instead). I tried setBounds but it didn't do anything, and I don't see a method for maximizing it; what am I missing? Update: on Windows at least, the system file dialog remembers size and maximize state even across program invocations, so the user can set it to the desired size just once and it will stay that way; that seems sufficient, so I will leave it at that.

    Read the article

  • Thousands separator in .Net/F#

    - by rwallace
    What's the recommended way to print an integer with thousands separator? Best I've come up with so far is let thousands(x:int64) = String.Format("{0:0,0}", x) Which works in most cases, but prints zero as 00.

    Read the article

< Previous Page | 1 2