freenode/#lisp - IRC Chatlog
Search
1:37:35
oni-on-ion
its possible to do custom formats ? for eg., print digit from 1-26 for alphabet: "abcd -> 1234"
1:39:27
specbot
Tilde Slash: Call Function: http://www.lispworks.com/reference/HyperSpec/Body/22_ced.htm
1:44:03
no-defun-allowed
I believe it was this part that tripped me up: If name does not contain a ":" or "::", then the whole name string is looked up in the COMMON-LISP-USER package.
1:50:54
no-defun-allowed
I assume it could be so compilers could generate code for FORMAT rather than interpreting the string. If that rule wasn't there, the effect would be dependent on the current package, but that doesn't seem too difficult to manage
2:22:39
jasom
I've used that for escaping strings: (format X "Foo \"~/pkg:escape/\"" bar) is much more obviously correct that (format X "foo \"~a\"" (escape bar)), particularly when you have a long format string or many arguments.
2:26:57
pjb
(format nil "Foo ~S bar" "Hello \" World! \\ <-- ha! \"") #| --> "Foo \"Hello \\\" World! \\\\ <-- ha! \\\"\" bar" |#
2:53:24
vms14
what's the "correct" way for having a group of labelled functions with local variables, should I use let and put the labels inside that let, or make the labelled functions receive them as argument? two of them are recursive and one gets called from another, but needs an argument that the callee does not need
2:54:24
vms14
sorry if you cry with the code, but it's a bad implementation of a image format I've created
2:55:00
vms14
the image will be a list of positive and negative numbers and the first item will be the width of the image
2:55:58
vms14
positive numbers refer to a color and negative numbers mean steps or points to draw with the current color
4:20:03
vms14
Josh_2: ty but now I need to create a paint software able to export to this weird format I've created
4:21:06
vms14
and I have no idea about how I should do it, but since will be for basic pixel art stuff it should be easier
4:28:52
vms14
oni-on-ion: I'm using clx and I saw no way to import images more than monochrome bitmaps
4:30:30
vms14
new-clx has support for xpm format, but the old one not, I use the "old" one since I target sbcl
4:32:29
oni-on-ion
could always hook up opengl to the window, might be helpful for higher color and hardware acceleration if neede
4:35:12
oni-on-ion
nice =) couple months ago i got some raw pixel blitting happening and it was very fast. so one can use any image loader
4:35:28
oni-on-ion
like the recent PNG library for CL which is nice n fast (compared to the previous one, afaik)
4:36:39
vms14
if you want to get started I recommend to google for "simple clx", they're simple examples and knowing xlib you'll easily get the difference
4:37:11
oni-on-ion
i can imagine =) however i am just using raylib for now. its a nice library, than SDL(2), and works for win32 and the web as well.
4:37:35
oni-on-ion
for using opengl, i had it rendering Cairo onto opengl texture then to window in real time at hyper speed on old hardware
4:39:19
oni-on-ion
(cairo because i needed vector and also font. also the API is just about interchangeable (especially with ocaml!!) with html5 canvas so that my work could run on any modern system incl. mobile and game console)
4:43:21
oni-on-ion
cool =) i honestly would too but i want to show my friends who only have mobile, and my tablet is stuck with windows8.1
6:08:55
pjb
oni-on-ion: cliki.net references several graphic toolkits. I would suggest pgl, since it's very simple. (However it's not native). Depending on the sophistication of your paint application, and the target systems, McCLIM or CLX could be good choices too.
6:11:26
oni-on-ion
i think it was vms14 who is doing current clx work. i will regard this new information
8:11:57
Harag
What should the method-combination-type-name be in find-method-combination if I am trying to check if method z has a specialization on class a for (defmethod z ((var a)))
8:39:12
beach
Harag: I am thinking you probably want to call METHOD-SPECIALIZERS on every method on Z instead.
9:18:16
Harag
but (find-method #'z '() (list (find-class 'b))) gives me an error, I was expecting nil ??
9:36:11
phoe
_death: find-method is going to signal an error anyway if you call it like (find-method #'z '() (list nil))
9:40:32
Harag
_death: thanx did not see errorp parameter, and I should never have the nil issue so its ok
9:42:31
_death
phoe: the misunderstanding is that you think I referred to find-class, while I referred to find-method
9:43:33
Harag
find-class was just to simplify the example I am actually looping through a list of super classes
12:03:40
phoe
so the correct printed value in that case would be "1.1" because we do not want to lose precision and since we print that decimal place anyway
12:08:04
phoe
so I argue, following jackdaniel's advice, that ANSI-TEST is incorrect in this case (;
12:10:09
jackdaniel
"hen a sequence of digits, containing a single embedded decimal point, is printed; this represents the magnitude of the value of arg times 10^k, rounded to d fractional digits. " and *after* that we have "If it is impossible to print the value in the required format then …"
12:10:35
jackdaniel
so this test seems to be correct given we follow the order in which things are specified in ~f section (22.3.3.1)
12:11:38
jackdaniel
as in: first we round to number of fractional digits (in our case 0), then we add extra space to have a float
12:16:42
jackdaniel
you shouldn't have highlighted me, now that you did you have the above disagreement ,p
12:17:12
jackdaniel
w is the width of the fileld to be printed and d is the number of digits to print after the decimal point - literally the first paragraph
12:19:37
jackdaniel
if the parameter d is omitted, then there is no constraint on the number of digits to appear after the decimal point. a value is chosen for d ...
12:20:33
phoe
...except that if the fraction to be printed is zero, then a single zero digit should appear after the decimal point if permitted by the width constraint.
12:20:51
jackdaniel
I should start working as a voice over; where I read the CLHS in a dramaticcal voice :)
12:23:34
jackdaniel
as in "if permitted by the width constraint" in case that "d is ommited" -- it is a tautology, because "the next arg is printed as float", and "1234." is not float
12:24:17
jackdaniel
so w /always/ permits the last 0 due to the paragraph about too small field width
12:24:29
phoe
If the parameter d is omitted, then there is no constraint on the number of digits to appear after the decimal point. A value is chosen for d in such a way that as many digits as possible may be printed subject to the width constraint imposed by the parameter w and the constraint that no trailing zero digits may appear in the fraction, except that if the fraction to be printed is zero, then a single zero digit
12:24:59
jackdaniel
and width constraint always permits a digit after the decimal point because of the above
12:26:22
jackdaniel
because if it may, then it stays in opposition to the first paragraph, argument is then not printed as a float
12:26:55
jackdaniel
I know what it means, and I'm saying that it is arguable that it is a correct specifier for ~f
12:27:44
phoe
especially because already 1. means a different thing in CL - namely, read this in base 10
12:28:13
jackdaniel
I've taken the interpretation that if d is explicitly set to 0 then user knows what they do, but imo it wouldn't be violating the spec if implementation signaled an error for d=0
12:29:34
phoe
if we print 1.1, then one is the first digit before the point and the other is the point
12:39:24
phoe
jackdaniel: I'd actually hold on to that - this is the part that describes the constraints for auto-choosing D if the user does not provide it themselves
12:39:44
jackdaniel
I do not agree with such interpretation, I've only said that I wouldn't say that if implementation signals error for d=0 is violating the spec
12:40:08
jackdaniel
in fact I've decided that allowing specifying d=0 is more useful and left it that way
12:40:34
phoe
if we tell the float-printer that "0 is the number of digits to print after the decimal point"
12:41:08
jackdaniel
"is rounded to d fractional digits" imo refers to *specified* d, and if d is not specified we take whatever fits w and after that we match value of d
12:42:18
phoe
if we follow it this way, then we do not specify D, so we DO NOT round number 1.1 to D specified digits
12:43:43
jackdaniel
I think you go in circles, I disagree with your interpretation and I've said why above (a few times), I have other things to do now
12:47:58
jackdaniel
no, because disregarding how you specify D, if W is 2, then you'll have 1.0 here
12:54:22
phoe
"Exactly w characters will be output." This is impossible to satisfy because the only float that we can print in two characters is 0.0. Therefore, "the scaled value is printed using more than w characters, as many more as may be needed."
12:55:00
phoe
So now "a sequence of digits, containing a single embedded decimal point, is printed; this represents the magnitude of the value of arg times 10^k, rounded to d fractional digits."
12:55:42
phoe
I cannot round the value to D digits because D was not provided. So either "a value is chosen for D" right now, or I signal a type error in my head.
12:57:16
phoe
I am trying to literally follow the algorithm from the spec. (And I silently hope that I'm doing it correctly.)
13:04:52
jackdaniel
only during "then a sequence of digits ... is printed" the fourth paragraph is triggered, that you print the scaled value with as many character as is needed. no mention of rounding now (only about scaling by factor k)
13:05:53
jackdaniel
so you print first character, second character, and then you add as many characters as needed to achieve a valid float from already printed characters
13:06:47
nirved
jackdaniel: "except that if the fraction to be printed is zero, then a single zero digit should appear after the decimal point if permitted by the width constraint."
13:11:17
phoe
"Then a sequence of digits, containing a single embedded decimal point, is printed; this represents the magnitude of the value of arg times 10^k, rounded to d fractional digits."
13:11:34
phoe
"a sequence of digits (...) represents the magnitude of the value of arg times 10^k, rounded to d fractional digits."
13:11:38
jackdaniel
you can't fit the number in width, so you do not round it beforehand, I've said it explicitly above
13:14:04
pjb
all implementations print "1." for ~2F but ecl which prints "1.0"; I'd deem them all wrong.
13:14:24
phoe
jackdaniel: if it's correct, then I've arrived at a conclusion that D is required to compute the sequence of digits that is then printed
13:15:08
nirved
"single zero digit should appear after the decimal point if permitted" makes it clear that a zero might not appear after decimal point
13:15:25
jackdaniel
jackdaniel> only during "then a sequence of digits ... is printed" the fourth paragraph is triggered, that you print the scaled value with as many character as is needed. no mention
13:15:32
jackdaniel
14:06 < jackdaniel> so you print first character, second character, and then you add as many characters as needed to achieve a valid float from already printed characters
13:16:45
phoe
> so you print first character, second character, and then you add as many characters as needed to achieve a valid float from already printed characters
13:17:45
phoe
now let me parse "only during "then a sequence of digits ... is printed" the fourth paragraph is triggered, that you print the scaled value with as many character as is needed. no mention of rounding now (only about scaling by factor k)"
13:18:39
jackdaniel
(handler-case (print-rounded arg) (overlow () (print-valid-digits arg) (add-missing-part)))
13:18:42
phoe
so you mean that the paragraph "Then a sequence of digits (...) is printed" does NOT invoke the paragraph "A value is chosen for d (...)" ?
13:20:02
jackdaniel
so in this exceptional case we indeed treat d as 0 and add .0 to have a valid float
13:20:48
nirved
does "containing a single embedded decimal point" mean that the decimal point must be surrounded by digits?
13:21:18
phoe
I still do not understand *this* part - why do we treat D as 0? Where does that page specify it? Why is D even allowed to be 0 if it means "print 0 decimal digits" which in turn implies that the number is not printed as a float which contradicts the very first paragraph of ~F?
13:22:13
jackdaniel
we treat D as 0 because W is to small to hold more D. Then we add .0 to have a valid float.
13:22:53
phoe
"If the overflowchar parameter is omitted, then the scaled value is printed using more than w characters, as many more as may be needed."
13:23:05
phoe
this means to me that W might as well be 3, since we print using three characters anyway
13:23:14
jackdaniel
and by we treat D as 0 I mean the number of fractional digits we round to, not how many fractional digits are printed.
13:23:46
jackdaniel
also, "we use more characters as needed" is not equivalent to "W is now as many characters as we need"
13:26:07
phoe
I will annotate the ANSI-TEST with this reasoning, so other people will luckily not need to have this discussion again.