Re: [Chicken-hackers] [PATCH] Apply the same naming scheme for .so libs in libs target
* felix winkelmann fe...@call-with-current-continuation.org [130204 21:29]: I'm not sure about this. I know that the current behaviour is not fully correct, but I repeatedly had problems the other way round, I think mostly in the situation when I ran freshly built binaries in the current build-directory, without installation (this may sound peculiar, but I need this for testing). Are you runnning make libs install-dev then? I always wondered what the usage of these targets is... The patch should not affect the usual make targets at all. At least as I read it atm... I'm often not installing, especially when I test the compiler. For running make check, I usually install with PREFIX=$PWD. Ok, let me describe what I am doing instead. I want to build a cross-chicken for the host, so I follow the instructions at http://api.call-cc.org/doc/chicken/cross-development and run the make call like this (on a 64bit linux x86 machine): make ARCH=\ PREFIX=/usr\ PLATFORM=linux\ HOSTSYSTEM=mipsel-openwrt-linux-uclibc\ DESTDIR=$HOME/src/nanonote/cross-chicken\ TARGET_FEATURE=-no-feature x86 -feature mips\ libs install-dev It builds fine, but the cross-chicken tree is broken: cross-chicken `-- usr |-- include | `-- chicken | |-- chicken-config.h | `-- chicken.h |-- lib | |-- chicken | | `-- 7 | | `-- types.db | |-- libchicken.a | `-- libchicken.so - libchicken.so.7 `-- share `-- chicken As you can see the libchicken.so.7 is missing. I don't know how this worked in the past, the lines doing the install have been there untouched since the import from svn... Am I doing this The Right Way (Is this side up?)? Thanks, Christian -- In the world, there is nothing more submissive and weak than water. Yet for attacking that which is hard and strong, nothing can surpass it. --- Lao Tzu ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] platform auto-detection mechanism
On Sun, Feb 3, 2013 at 10:02 PM, John Cowan co...@mercury.ccil.org wrote: Michele La Monaca scripsit: Incidentally a good reason not to rely on gcc to detect the platform. No autodetection will ever work with MSVC, for one might have both that and mingw installed in the same path. Yes, sure. No autodetection can detect user's intentions if there are alternatives. But I think that the specific case you raised (mingw and MSVC both present) is easy to work out as my idea was to use the native nmake for MSVC (even if it would mean a complete rewrite of the build process). So make will continue to trigger mingw, while nmake will trigger MSVC. Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Thu, Feb 7, 2013 at 12:20 AM, Alex Shinn alexsh...@gmail.com wrote: Hi, On Thu, Feb 7, 2013 at 3:20 AM, Michele La Monaca mikele.chic...@lamonaca.net wrote: [..] I don't think (substring2 foo 0 10) - foo is conceptually wrong or sloppy as long as you know exactly what the semantic of the function is (give me at most N chars - perl or give me chars up to the Nth position or up to the end of the string whatever the first - python, ruby). Truncating a string to a maximum length is a common operation for formatting - I was surprised there was no easy way to do this with SRFI-13. But in this case the start argument isn't needed and distracting. You probably want something like: Well, no. If I wanted a truncate function I would have asked for it. I used 0 as START to simplify the exposition (in that case the END parameter can be interpreted as length or position indifferently). Anyway, thanks for raising the point. Maybe the reason there is no string-truncate around is that a sane substring function would just do the job? Regards, Michele (string-truncate foo 10) = foo (string-truncate foofoofoofoo 10) = foofoofoof In the fmt egg: (fmt #f (trim 10 foo)) = foo Conflating this with substring is confusing and hides potential errors, as others have pointed out. -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] file=? function to compare two files
On Fri, Jan 25, 2013 at 6:36 PM, Christian Kellermann ck...@pestilenz.org wrote: * John Cowan co...@mercury.ccil.org [130125 17:33]: Michele La Monaca scripsit: I wasn't able to spot this kind of function in the library so I wrote it myself. Not sure if files.scm is the right place for that. Not sure either if inode-numbers equality in Windows is enough to state that two files are actually the same file. Some tuning might be needed, not yet very fluent/knowledgeable in scheme... unfortunately. For sure you have to check for equality in st_dev as well as st_ino. Even on Posix systems, inode numbers are only unique to a specific device. In any case, st_ino is garbage on Windows systems (other than Cygwin). Or don't make sense on network filesystems... Yes, sure. That was the primary use case when I thought about the FORCE-COMPARISON option. Thanks. Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] file=? function to compare two files
On Fri, Jan 25, 2013 at 5:32 PM, John Cowan co...@mercury.ccil.org wrote: Michele La Monaca scripsit: I wasn't able to spot this kind of function in the library so I wrote it myself. Not sure if files.scm is the right place for that. Not sure either if inode-numbers equality in Windows is enough to state that two files are actually the same file. Some tuning might be needed, not yet very fluent/knowledgeable in scheme... unfortunately. For sure you have to check for equality in st_dev as well as st_ino. Even on Posix systems, inode numbers are only unique to a specific device. Yes, sure. It's already implemented this way. In any case, st_ino is garbage on Windows systems (other than Cygwin). Are you implicitly saying that I have to force the byte-by-byte comparison in Windows? Thanks. Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] file=? function to compare two files
Michele La Monaca scripsit: In any case, st_ino is garbage on Windows systems (other than Cygwin). Are you implicitly saying that I have to force the byte-by-byte comparison in Windows? I don't know enough about Windows to say that. I'm only saying what will *not* work, because st_ino's value is unreliable. -- John Cowan co...@ccil.orghttp://www.ccil.org/~cowan Is it not written, That which is written, is written? ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Wed, Feb 6, 2013 at 12:47 AM, Felix fe...@call-with-current-continuation.org wrote: # perl -e 'print substr(ciao,0,10);' ciao # ruby -e 'puts ciao[0..10]' ciao # python -c 'print ciao[0:10];' ciao # csi -e '(print (substring ciao 0 10))' Error: (substring) out of range 0 10 Call history: syntax (print (substring ciao 0 10)) syntax (substring ciao 0 10) eval(print (substring ciao 0 10)) eval(substring ciao 0 10) -- The string is shorter than the limit you gave to substring in the third argument. Of course you know that, but why did you pass an incorrect length in the first place? This looks like it does what you want: csi -e '(print (substring ciao 0))' Well, no. I was looking for a python-like substring function. Anyway, thanks for the (substring ciao 0) trick, it is a very handy method to trim strings on the left (not documented in the wiki, btw): (substring ciao 1) = iao In my ideal world, there would room also for that: (substring ciao 0 -1) = cia but I know, I know... it will never happen :-( Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
Michele La Monaca scripsit: Well, no. I was looking for a python-like substring function. If that's all you really wanted, the slice egg (to which you have already been referred; docs at http://wiki.call-cc.org/eggref/4/slice) does everything you are asking for, negative and past-the-end indices and all. It even slices lists and vectors as a bonus. But no, what you are showing you actually want is to complain about the meaning of the name substring. That's not a discussion anyone else thinks is worth having. -- You are a child of the universe no less John Cowan than the trees and all other acyclichttp://www.ccil.org/~cowan graphs; you have a right to be here.co...@ccil.org --DeXiderata by Sean McGrath ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Small improvement for the inline egg
Hello again, Moritz Heidkamp mor...@twoticketsplease.de writes: 1. It dumps compilation results in ~/.cache by default. This, however, is a bit like dumping stuff in /usr/share so I think it would be better to make this ~/.cache/chicken-inline or something. Mario just pointed out to me in #chicken that the current default is actually .cache, not ~/.cache. It just happened to be that I ran csi from my home when trying it out and then I didn't properly read the code when hacking up the patch. Considering that this default directory is apparently meant as a relative path I propose the attached new version which sets it to .chicken-inline by default. Moritz Index: inline.scm === --- inline.scm (revision 28291) +++ inline.scm (working copy) @@ -39,7 +39,7 @@ (define (inline-eval x . o) (inline-compile x (if (pair? o) (car o) ) #t)) -(define-constant default-inline-cache-name .cache) +(define-constant default-inline-cache-name .chicken-inline) (define windows-shell (foreign-value C_WINDOWS_SHELL bool)) (define inline-cache (make-parameter default-inline-cache-name)) @@ -94,7 +94,6 @@ (zero? (system (sprintf cmp -s ~A ~A (qs a) (qs b ))) (define (ensure-cache) - (unless (file-exists? (inline-cache)) -(create-directory (inline-cache)) ) ) + (create-directory (inline-cache) #t) ) ) ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 2:23 AM, Michele La Monaca mikele.chic...@lamonaca.net wrote: On Thu, Feb 7, 2013 at 12:20 AM, Alex Shinn alexsh...@gmail.com wrote: Hi, On Thu, Feb 7, 2013 at 3:20 AM, Michele La Monaca mikele.chic...@lamonaca.net wrote: [..] I don't think (substring2 foo 0 10) - foo is conceptually wrong or sloppy as long as you know exactly what the semantic of the function is (give me at most N chars - perl or give me chars up to the Nth position or up to the end of the string whatever the first - python, ruby). Truncating a string to a maximum length is a common operation for formatting - I was surprised there was no easy way to do this with SRFI-13. But in this case the start argument isn't needed and distracting. You probably want something like: Well, no. If I wanted a truncate function I would have asked for it. I used 0 as START to simplify the exposition (in that case the END parameter can be interpreted as length or position indifferently). You didn't use it just to simplify, because the task you described in English was give me at most N chars. This is a common task, and always has a START of 0. There may be cases in Python where you first want to take the substring from START to the end of the string, and then want to truncate the result to END-START chars. This becomes an idiom in Python, so it seems natural to you, but there is always a specific reason you want to truncate separate from the substring you are taking. In Scheme this becomes (string-truncate (string-copy str start) max-len) You could combine these two functions (slice str start (- max-len start)) but this hides what you're actually doing and likely not as common, so is probably a bad idiom in Scheme. It doesn't make sense to provide such artificially combined functions. For example, you may notice sometimes you want to take a substring and then lowercase the result, but that doesn't mean it's worth defining a substring-downcase function. To add to the earlier rants abouts the dangers of DWIM behavior, I had a nasty bug in one of my Python programs the other day. We have an API for tasks which produce file outputs, and for convenience if there's only a single output we just return that, otherwise we return a tuple of strings. I had a task where I wanted to copy the first result to a separate directory, and this was a task that returned a tuple, so I used outputs[0]. Unfortunately, after some refactoring this became a task which only returned one output, so outputs became a string and outputs[0] was /! The program was still perfectly valid, and gave me the command-line: cp -R / /path/to/destination Fortunately we have lots of extra checks and I caught this before ever executing it, but it was scary to even just see that. -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
How strange, I thought no one was interested in the discussion. Anyway, with John's permission just a few inline clarifications. On Thu, Feb 7, 2013 at 11:59 PM, Alex Shinn alexsh...@gmail.com wrote: [...] You didn't use it just to simplify, because the task you described in English was give me at most N chars. http://lists.nongnu.org/archive/html/chicken-hackers/2013-02/msg00058.html give me at most N chars starting from a certain position in the string Ok, in another mail I gave a shortened version but, well, I think the context was clear. This is a common task, and always has a START of 0. What? what? what? There may be cases in Python where you first want to take the substring from START to the end of the string, and then want to truncate the result to END-START chars. This becomes an idiom in Python, so it seems natural to Sorry, never used Python in my life. I used it as an example because I think it's a commonly known language. Not by me, unfortunately, so I don't believe I completely understand what you are trying to say. you, but there is always a specific reason you want to truncate separate from the substring you are taking. In Scheme this becomes (string-truncate (string-copy str start) max-len) You could combine these two functions (slice str start (- max-len start)) but this hides what you're actually doing Don't think so. Really don't think so. and likely not as common, so is probably a bad idiom in Scheme. It doesn't make sense to provide such artificially combined functions. Again (last time I promise), I don't think that: starting from a certain position give me at most N chars or starting from a certain position give me chars up to the Nth position or up to the end of the string whatever the first are artificially combined functions. They are exactly what they mean. Anyway, I think I had enough of that. I respect your opinions, please try to respect mine and let's stop this discussion. Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 10:14 AM, Michele La Monaca mikele.chic...@lamonaca.net wrote: starting from a certain position give me chars up to the Nth position or up to the end of the string whatever the first Can you provide a real-world example where you'd want to use this function? -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
Alex Shinn scripsit: Can you provide a real-world example where you'd want to use this function? I used to use it all the time in Perl, where it is the normal behavior of the substr() function, to pull a fixed-width field out of a line of text without having to worry about short lines. If the field was at the end of the line, the result was short; if the field was not present, the result was the empty string. In some contexts, I would then concatenate spaces to it and truncate the result to the desired width. -- Barry thirteen gules and argent on a canton azure John Cowan fifty mullets of five points of the second, co...@ccil.org six, five, six, five, six, five, six, five, and six. --blazoning the U.S. flag http://www.ccil.org/~cowan ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 10:45 AM, John Cowan co...@mercury.ccil.org wrote: Alex Shinn scripsit: Can you provide a real-world example where you'd want to use this function? I used to use it all the time in Perl, where it is the normal behavior of the substr() function, to pull a fixed-width field out of a line of text without having to worry about short lines. If the field was at the end of the line, the result was short; This is where you have a contradiction - the field is fixed width but the full width is not available, which means you have an invalid format. Could you be more specific in your example? If the goal is to extract the last field, then you use substr with no end param. If the goal is to take a fixed field you should be taking that. If the format allows either then the format itself is ambiguous, which means you have a _much_ bigger problem than whatever language idioms you use. -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
Alex Shinn scripsit: This is where you have a contradiction - the field is fixed width but the full width is not available, which means you have an invalid format. Yes, in one sense. However, when transferring textual data between heterogeneous systems it is very common for trailing spaces to be discarded willy-nilly, and the approach described recovers from that nicely. Be liberal in what you accept. If the goal is to take a fixed field you should be taking that. If the format allows either then the format itself is ambiguous, which means you have a _much_ bigger problem than whatever language idioms you use. Purism has its place, but is not always the appropriate response to Real World issues. In this case, kicking back such records as invalid/ambiguous format simply would not have served the organization's goals. -- In my last lifetime,John Cowan I believed in reincarnation;http://www.ccil.org/~cowan in this lifetime, co...@ccil.org I don't. --Thiagi ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 11:50 AM, John Cowan co...@mercury.ccil.org wrote: Alex Shinn scripsit: If the goal is to take a fixed field you should be taking that. If the format allows either then the format itself is ambiguous, which means you have a _much_ bigger problem than whatever language idioms you use. Purism has its place, but is not always the appropriate response to Real World issues. In this case, kicking back such records as invalid/ambiguous format simply would not have served the organization's goals. I was not suggesting kicking it back. I was suggesting if it was the last field then just use substr($line, $n). That sounds like the definition of the format you're describing, though you're not giving a concrete example so I can't be sure. If there are additional restraints on this field then you should handle them as well, and if you want to handle those restraints liberally you can do so. For example, if the length of the last field should be no longer than $limit, you can check this: if (len($field) $limit) { print STDERR found trailing junk at end of line: $field; $field = substr($field, 0, $limit); } The warning is important, and this again emphasizes that there are two _unrelated_ functions - extraction and truncation - and that combining them is a bad idea. -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
Alex Shinn scripsit: The warning is important, and this again emphasizes that there are two _unrelated_ functions - extraction and truncation - and that combining them is a bad idea. The warning is important -- when it's important. In my case, it was important to avoid cluttering the exception log with spurious complaints about the results of a process outside anyone's control. In any case, that has zero to do with whether it makes sense to package this behavior as a procedural abstraction. Please note that I am *not* arguing that Chicken's substring should behave this way, just that a convenient implementation of the loose behavior does have use cases. -- The Imperials are decadent, 300 pound John Cowan co...@ccil.org free-range chickens (except they have http://www.ccil.org/~cowan teeth, arms instead of wings, and dinosaurlike tails).--Elyse Grasso ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 12:26 PM, John Cowan co...@mercury.ccil.org wrote: Alex Shinn scripsit: The warning is important, and this again emphasizes that there are two _unrelated_ functions - extraction and truncation - and that combining them is a bad idea. The warning is important -- when it's important. In my case, it was important to avoid cluttering the exception log with spurious complaints about the results of a process outside anyone's control. Then comment out the logging, or use a verbosity level. The most important thing with a hacky language and hacky formats is to be precise about your parsing. In any case, that has zero to do with whether it makes sense to package this behavior as a procedural abstraction. Please note that I am *not* arguing that Chicken's substring should behave this way, just that a convenient implementation of the loose behavior does have use cases. I think none of the Schemers are arguing that substring should be changed. I'm arguing further that the slice function is an artifact of languages that have slicing as syntax, but here is actually a confused composition of two operations. The only example provided was fairly obscure and it was indeed a composition, even if you don't think it's worth separating them for logging or other handling. -- Alex ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] substring function and bounds checks
On Fri, Feb 8, 2013 at 5:43 AM, Alex Shinn alexsh...@gmail.com wrote: operations. The only example provided was fairly obscure and it was indeed a composition, even if you don't think it's worth separating them for logging or other handling. At the prompt of your shell type: # ls ?a_well_thought_out_substring_function_would_do_this_job* Regards, Michele ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers