Re: Accessing multiple values from C
Hi Julian, Julian Graham skribis: >>> Not yet. You interested in adding scm_c_value_ref (SCM, size_t) to the >>> API, and documentation to api-control.texi? If you do it soon, it >>> will make it into 2.0.4. >> >> Sure. Gimme a day or so and I'll have something for review. > > Find attached a patch. Let me know if I missed anything. Looks good to me, thanks! > +@deffn {C Function} scm_c_value_ref (values, idx) > +Returns the value at the position specified by @var{idx} in the Should be “Return” here. Andy: OK to apply? Ludo’.
Re: propagating a coding setting across source files
Hi, Mike Gran skribis: > I tried to dig through the logic of this the other day, and I'm not > sure that your suggestion can work. If "load" ends up calling > "primitive-load", then any file without a "coding:" line is UTF-8. > %default-port-encoding doesn't enter in to it. Right. So what Sven is asking for, propagating source file encoding programmatically, is not possible AFAIK. Sven: you really need to add the “coding:” cookie to each and every file. Thanks, Ludo’.
Re: Guile support in GNU make
Hi Paul, And thanks for the great news! :-) Paul Smith skribis: > On Sun, 2012-01-15 at 09:51 +0100, Thien-Thi Nguyen wrote: [...] >> - The ‘#t => t’ distinguishes the symbol t from others, which feels wrong. >> I suggest #t => ""; #f => error. > > Hm. The problem with this is that we can't easily use Guile booleans in > GNU make. For example, the syntax for make's $(if ...) function is: > > $(if ,[,]) > > The is expanded as a makefile expression and if it's empty > it's considered false. If it's non-empty it's considered true. Would it be possible for Make to delay the conversion of SCMs to strings, and in turn to differentiate between conditions as strings, and conditions that are SCMs? In the latter case, it could just apply scm_is_true to the condition. Thanks, Ludo’.
Re: Accessing multiple values from C
On Sun 15 Jan 2012 22:47, l...@gnu.org (Ludovic Courtès) writes: Not yet. You interested in adding scm_c_value_ref (SCM, size_t) to the API, and documentation to api-control.texi? If you do it soon, it will make it into 2.0.4. >>> >>> Sure. Gimme a day or so and I'll have something for review. >> >> Find attached a patch. Let me know if I missed anything. > > Looks good to me, thanks! > > Andy: OK to apply? If it looks good to you, sure! I haven't had a chance to review anything besides local-eval in a few days :/ Happy hacking, Andy -- http://wingolog.org/
Re: propagating a coding setting across source files
On Sun 15 Jan 2012 22:51, l...@gnu.org (Ludovic Courtès) writes: > Mike Gran skribis: > >> I tried to dig through the logic of this the other day, and I'm not >> sure that your suggestion can work. If "load" ends up calling >> "primitive-load", then any file without a "coding:" line is UTF-8. >> %default-port-encoding doesn't enter in to it. > > Right. So what Sven is asking for, propagating source file encoding > programmatically, is not possible AFAIK. Sven: you really need to add > the “coding:” cookie to each and every file. Is possible to provide such an interface? I agree that coding: is the right thing, but there's a lot of legacy code out there. If it's possible to support without much effort, we probably should do so. Andy -- http://wingolog.org/
Re: Guile support in GNU make
On Sun, 2012-01-15 at 23:02 +0100, Ludovic Courts wrote: > And thanks for the great news! :-) I promoted the feature to GNU make CVS (I know, still CVS!!) on Savannah. I hope to generate a test dist file sometime this week. I'll email when it's available if people want to take a look. > Paul Smith skribis: > >> - The ‘#t => t’ distinguishes the symbol t from others, which feels wrong. > >> I suggest #t => ""; #f => error. > > > > Hm. The problem with this is that we can't easily use Guile booleans in > > GNU make. For example, the syntax for make's $(if ...) function is: > > > > $(if ,[,]) > > > > The is expanded as a makefile expression and if it's empty > > it's considered false. If it's non-empty it's considered true. > > Would it be possible for Make to delay the conversion of SCMs to > strings, and in turn to differentiate between conditions as strings, and > conditions that are SCMs? I don't think this is possible. Make has no "data types" at all. It just manipulates strings--every operation in make is a string operation, and the "results" of operations are just constructing new string buffers by doing string manipulations, then passing that string to the next function (or whatever). There's just no facility anywhere internal to make to store or manipulate a non-string item. I suppose one option would be to have #f translate to the string "#f" and change the definition in make of "false" to be "either the empty string OR the string #f". Since "#" is a comment character in make it's highly unlikely (although not impossible) someone would have that as a valid value. However, this would be a lot of effort (finding all the places in make that use the empty string as "false" and modifying them). And I'm not sure it wouldn't cause other issues. I think, all in all, it's better to leave it as-is unless someone can point out a real problem with it (besides a general unpleasant aftertaste). -- --- Paul D. Smith Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.net "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Re: salutations and web scraping
Andy, Il giorno 10 gennaio 2012 22:46, Andy Wingo ha scritto: > Hi Catonano, > > On Fri 30 Dec 2011 23:58, Catonano writes: > > > I´m a beginner, I never wrote a single line of LISP or Scheme in my life > > and I´m here for asking for directions and suggestions. > > Welcome! :-) > thank you so much for your reply. I had been eagerly waiting for a signal from the list and I had missed it ! I´m sorry. The gmail learning mechanism hasn´t still learned enough about my interest in this issue, so it didn´t promptly reported about your reply. I had to dig inside the folders structure I had layed out in order to discover it. As for me I haven´t learned enough about the gmail learning mechaninsm woes. I guess we´re both learning, now. Well, I was attempting a joke ;-) > > my boldness is such that I´d ask you to write for me an example > > skeleton code. > > > Hey, it's fair, I think; that is a new part of Guile, and there is not a > lot of example code. > > Thanks, Andy, I´m grateful for this. Actually I managed to set up geiser, load a file and get me delivered to a prompt in which that file is loaded. Cool ;-) But there are still some thing I didn´t know that your post made clear. > Generally, we figure out how to solve problems at the REPL, so fire up > your Guile: > > $ guile > ... > scheme@(guile-user)> > > (Here I'm assuming you have guile 2.0.3.) > > Use the web modules. Let's assume we're grabbing http://www.gnu.org/, > for simplicity: > > > (use-modules (web client) (web uri)) > > (http-get (string->uri "http://www.gnu.org/software/guile/";)) > [here the text of the web page gets printed out] > Ok, I had managed to arrive so far (thanks to the help received in the guile cannel in irc) > > Actually there are two return values: the response object, corresponding > to the headers, and the body. If you scroll your terminal up, you'll > see that they get labels like $1 and $2. > I didn´t know they were 2 values, thanks > > Now you need to parse the HTML. The best way to do this is with the > pragmatic HTML parser, htmlprag. It's part of guile-lib. So download > and install guile-lib (it's at http://www.non-gnu.org/guile-lib/), and > then, assuming the html is in $2: > I had seen those $i things but I hadn´t understood that stuff was "inside" them and that I could use them, so I was using a lot of (define this that). And this is probably why I missed the two values returned by http-get. Thanks ! > > (use-modules (htmlprag)) > > (define the-web-page (html->sxml $2)) > And I didn´t know about htmlprag, thanks > > That parses the web page to s-expressions. You can print the result > nicely: > > > ,pretty-print the-web-page > thanks, I didn´t know this, either > > Now you need to get something out of the web page. The hackiest way to > do it is just to match against the entire page. Maybe someone else can > come up with an example, but I'm short on time, so I'll proceed to The > Right Thing -- the problem is that whitespace is significant, and maybe > all you want is the contents of "the in the in the > ." > > So in XML you'd use XPATH. In SXML you'd use SXPATH. It's hard to use > right now; we really need to steal > http://www.neilvandyke.org/webscraperhelper/ from Neil van Dyke. But > you can see from his docs that the thing would be > > > (use-modules (sxml xpath)) > > (define matcher (sxpath '(// html head title))) > > (matcher the-web-page) > $3 = ((title "GNU Guile (About Guile)")) > > I was going to attempt something along this line (sxml-match (xml->sxml page) [(div (@ (id "real_player") (rel ,url))) (str but I´m going to explore your lines too. I still wasn´t there, I had stumbled in something I thought it was a bug, but I also had something else to do (this is a pet project) so this had to wait. But I´ll surely let you know Thanks again for your help Bye Cato
Re: propagating a coding setting across source files
Hi! Andy Wingo skribis: > On Sun 15 Jan 2012 22:51, l...@gnu.org (Ludovic Courtès) writes: > >> Mike Gran skribis: >> >>> I tried to dig through the logic of this the other day, and I'm not >>> sure that your suggestion can work. If "load" ends up calling >>> "primitive-load", then any file without a "coding:" line is UTF-8. >>> %default-port-encoding doesn't enter in to it. >> >> Right. So what Sven is asking for, propagating source file encoding >> programmatically, is not possible AFAIK. Sven: you really need to add >> the “coding:” cookie to each and every file. > > Is possible to provide such an interface? Maybe a ‘guild compile’ option? Ludo’.
Mixing syntax-rule and indentifier-syntax
Hi, is it possible to define a macro that does one thing when it's in operator position and another when it's not? I want to define a macro `with-vectors` that transforms this: (with-vectors (v) (v 0) (set! (v 0) 'foo) (some-procedure v)) into this: (begin (vector-ref v 0) (vector-set! v 0 'foo) (some-procedure v)) So far I have this: (define-syntax with-vectors (syntax-rules () ((_ (id ...) exp ...) (let-syntax ((id* (syntax-rules () ((_ idx) (vector-ref id idx ...) exp ... But that obviously only works for the first case: (v 0). Regards, Tobias