Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v77761$1fmm0$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v77761$1fmm0$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Laroux <arketernal@protonmail.com>
Newsgroups: comp.lang.lisp
Subject: A drawing program on the REPL with GUI feedback
Date: Wed, 17 Jul 2024 01:36:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <v77761$1fmm0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 17 Jul 2024 03:36:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9571a32ec36600d94a8b511e24e04dd4";
	logging-data="1563328"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19mVvdqYQ2MECrXu6cvEf5E"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:b6CeZO77p82EwaDRI+GSPdF8ZOE=
Bytes: 4612

I'm designing a drawing program whose functionality will be fully
programmable on the REPL. There will be a canvas display. You can do
something like:

(draw (color (line '(0 0) '(10 10)) 1))

And a straight line from pixel coordinates 0, 0 to 10, 10 in color index 1
will be drawn. This is relatively easy. The line function returns a list
of coordinates. The color function associates a color index to each
coordinate, and the draw function colors each coordinate with the given
color (assuming a color palette previously defined).

But, when drawing it is most often the case that the end user wishes to
use the mouse to point at areas of the canvas upon which to draw. I would
like the functions to be completely ignorant of whether the values were
typed in directly at the REPL as my example above, or obtained from the
user via the mouse.

Even the color index could instead be a request for the user to select a
color from the color palette.

For example:

(draw (color (line '(ask) '(ask)) 1))

This would then prompt (both at the REPL and on the canvas) for the user
to enter the starting and ending coordinates for the line. The user could
just type the values into the prompt at the REPL, or move the mouse onto
the canvas click once, move and click a second time.

The GUI part, and acquisition of the mouse coordinates is not where I'm
stuck. I'm sure I could use something like SDL or Mcclim for this task.

But, what I am unsure about is how to make a generalized function which
can read a series of values from the user, and then pass them as
parameters to the given functions.

Let's just take the line function, for example. I guess it needs to be a
macro, so that it does not evaluate its terms. Okay, so macro "line" will
need to eventually call real function "line" which does the job of
calculating the pixel coordinates from the beginning to the end.

What I would like is for some ability to inspect the real function called
line to determine what parameters it requests. Then compare that with the
parameters passed into the macro.

In this case we can say "Ah, function line takes one or more coordinates.
If just one coordinate, it returns that one. If two, then a list of
coordinates between them. If three then a line from coordinate one to two,
and then from two to three, etc." Further, we passed in two "ask"
requests, so that would fill in exactly two coordinates for the line
function. Let's request them from the user.

Here are some other examples:

(line 'ask)
This should keep asking for coordinates until some other user input (maybe
the escape key) indicates the end of the list.

(line '(0 ask) '(10 ask))
This will ask for the y value of the coordinate for both the beginning and
the end

(line '(ask start-coord) '((+ 10 (car start-coord)) (+ 10 (cadr start-
coord)))
This will ask for the starting coordinate, and assign it to the variable
"start-coord." The ending coordinate will be ten pixels right and ten
pixels down (using screen coordinates) from the starting coordinate.

I may have the syntax incorrect. Maybe I need to always have "ask" in
parenthesis, as like a function.

But, the main part I wish to figure out is how to take an arbitrary set of
parameters that would normally be passed into a function, compare that to
the function's signature, and then request the user to "fill in the
blanks."

I think part of the solution includes having the function (I mean "line" 
in this instance) declare the type of its values. I think also there is a 
way to include documentation of each input parameter. That documentation 
could be used as the prompt at the REPL.

Thanks for any ideas you may have.