summaryrefslogtreecommitdiff
path: root/TODO
blob: 18ca8899f6485731a0e8c6a6dd7e80fefdf16add (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
Features you cannot find in the doco as working, should be mentioned
here.

This is an assorted collection of stuff that will be done, might be
done, or is an idea that I want to think about

Most of the items are marked in the code as well, with full explanation. 
grep for TODO and ugh/ugr/urg

*In a piece such as the Zipoli piece in mutopia/... there is a stray
`8' over every bar line when processed by LilyPond 1.1.25.

TODO before 1.2

	- cf'able ly2dvi  tagline.

	- make ly2dvi test page.

	- fix dynamics decently, ie. use kerning & ligatures.  Junk
TeX macros.


	- span bars. ->gallina 

*******
m=\notes\relative c'{
\voiceone
c1
\mark "A"; R1*3 \mark "B";
<{R1*3}{s1 \mark "C";}>
}

n=\notes\relative c'{
\voicetwo
c1 | c1 | c1 | c1 | c1 | c1 | c1 |
}

\score{ 
    \type StaffGroup <
       \type Staff = m <\m>
       \type Staff = n <\n>
    >

        \paper {
                \translator { \OrchestralScoreContext
                        markScriptPadding = "4.0";
               }
        }
}
*********

	* junk Text_def, use G_text_item in stead.

	* junk Script_def

	* fix partial measures in meaningful way.

	* fix AFM for BlueSky AFM files.

	* working notehead style.

	* add scripts to bars eg.  |^"bla" 

	* relative mode for mi2mu

	* uniformise recent feta contributions.
	- use SCM and Molecules for {accordeon stuff, }
	- bigger and fatter 4/4 C

	* make a SMOB of Atom and Molecule

	* sort out directory stuff.
	- --prefix option?
	- -I option per filetype?
	- kpathsea?

	* is \break broken? input/test/hara-kiri.ly

	* fix OrchestralScore and Hara-kiri (i.e., fix Coriolan)

**************
I also found a few bugs:

* The examples in input/test/bar-scripts.ly and score-bar-scripts.ly
  don't work. The problem seems to be that you can't define a 
  a score identifier and then use it in the \score block.


	- make separate MF chars for endings of ledger lines, and calc rest of lines.

 	* support_l_arr_ empty in staff-margin's G_staff_side_item

	* todo doc left/rightbeamcount


	* doc Single_malt_grouping_item

	* ly2dvi/lilypond logfile.

	* remove old preformats in RPM

************

How can I specify a chord whose duration is longer than a whole note?

 \type ChordNames { \chord{ A1*2-min } }

gives me a parse error.  And \times doesn't work either.  I can't use
a spacer note.  So it seems to be impossible to have long chords of
general length.  Of course, in the example above I can use \breve.
But what if I want a chord that lasts for 3 whole notes?  Or what
about 2.5 whole notes?  Is there a mechanism for getting this kind of
length?  


Why does my second extender request get junked in the following:

\score{
< \notes \relative c''{ 
     a4()b()c()d c()d()b()a }
   \type Lyrics \lyrics {
     foo1 __  bar2. __ _4 }
> }

It seems that \cr and \decr don't work any more.  

\score{
  \notes{
    a \cr b \rc c }
  \paper{linewidth=-1.;}
}

Gives me 

qq.ly:3:9: warning: can't find (de)crescendo to end:
    a \cr
          b \rc c }



Use of semicolons is still rather confusing.  They are obligatory
after some types of assignments and illegal after others.  

  \property foo=bar               illegal
  foo = 3 at top level            illegal
  foo = 3 inside \paper           obligatory               
  foo = \notes{ ...} top level    illegal
  foo = \translator{ } in \paper  obligatory

As far as I can tell, the sole accomplishment of this syntactic
irregularity is to keep the user as confused as possible.  


I was trying to get interstaff beams to work and did this:

\score{
\type GrandStaff <
\type Staff=one \notes\relative c'{
  \stemup
  [c8 c \translator Staff=two \stemup c c]
  \translator Staff=one
  \stemdown 
  [ b8 \translator Staff=two a8]
  \translator Staff=one 
  c4 
  }
\type Staff=two \notes{ \clef bass; s1 }
>
\paper{
		\translator{
			\GrandStaffContext
			minVerticalAlign = 3.0*\staffheight;
			maxVerticalAlign = 3.0*\staffheight;
		}
  linewidth = -1.;
}
}

The beams are at the right angle, but they aren't in the right place.



*******************


	* fractional chord durs.

	* hang Item on Spanner

	* remove Interval dim_ from Dimension_cache and rename the struct.

	* do --safe for PS output?

	* convert-mudela --output

	* Staff_margin (with a partial measure.)

	* fix "I've been drinking too much"

	* fix pletvisibility properties:
	  - bracket on/off/no-bracket-when-beam
	  - num on/off/no-num-when-beam

	* fix: standchen.

	* junk backlinks?

	* junk text{sharp,flat,etc}

	* fix convert-mudela manpage

	* decimal point in \paper {}

	*{  \voiceone <a'4.*2/3  d''4.*2/3 fis''4.*2/3>  [g''8 fis'' e''] d''4 |}
	 and=20
	 { \voicetwo  d'4 d'2.*2/3 } spacing

	* tied notes for MIDI

	* sharp /flat on trills (in MIDI ??)

	* scm-ify \property values.

	* move class Lookup {} into scm

BUGS:

	* collisions/voices \voiceone \voicetwo are broken; see 
 	  input/praeludium-fuga-E.ly
 	  mutopia/J.S.Bach/wtk1-fugue2.ly

	* fix: text on rests: rediculous dims

	* ly2dvi
	  - bottomnote for ly2dvi
	  - deps for ly2dvi

	* fix midi output:
	   - default duration?  duration must be not entered
	     explicitely on first note.

	* turn slope-damping on/off

	* c4 \! \> c4

	* tremolo stuff

	* gallina barlines.

	* fix height of / collisions with lyrics (chords), 
	   see input/test/vertical-text.ly; input/test/repeat.ly

	* latex bla.tex broken (titles / \lilyfooter stuff?)

	* msgfmt -o check?

	* \breathmark TeX macro 

	* catch GUILE errors?

	* add new glyphs to font.ly

	* formatting of input stuff. 

	* \notes{ a \< b \cr } vs \notes{ a \< b \! }

	* if possible, it might be nice for a warning to appear if someone does
	\translator with no name and without assigning it to an
	identifier.  

	* space after bars?

	* 'hinterfleisch' before bar (e.g. wtk1-fugue2)?

	* \type Voice \times 2/3 { [c8 c16 c16 c16 c16] }

	* fix singleStaffBracket

  	* repeat bars: need distance after ":|" and before "|:"

	Summary of minor spelling irregularities:
	-  capitalization/use of underscores in property names

	* fix SkipBars  -> skipBars

	* \shape 1st dim skipped? 

	* fix marks/barnumbers/marginal notes

	* broken scripts:
	lbheel = \script { "bheel" 0 0 -1  0 0 }
	rbheel = \script { "bheel" 0 0 1 0 0 }
	lbtoe = \script { "btoe" 0 0 -1 0 0 }
	rbtoe = \script { "btoe" 0 0 1 0 0 }
	lfheel = \script { "fheel" 0 0 -1  0 0 }
	rfheel = \script { "fheel" 0 0 1 0 0 }
	lftoe = \script { "ftoe" 0 0 -1 0 0 }
	rftoe = \script { "ftoe" 0 0 1 0 0 }
	
	and also
	
	portato= \script { "portato" 0 -1 0 1 0 }

STUFF
	* check out legal/(c) matters for scores.

	* check out GCC signatures?

	* Align_element::padding  ?

	* uniformise property names...
	  - ydirection <-> yDirection
	  - rather allow '_' in identifiers first (i.e. junk ^ and _),
	    and do y_direction?
	  - typo checks on property names?

	* use streambufs and iostream
	to provide IO handling for TeX stream, mudela stream, data-file.

	* seriously buffer TeX output (do profile of writing .5 mb TeX file.)

	* strip EXEs before installing

	* zip target for binary windows dist (JBR)

	* junking \skip req in lyrics

	* Language:
	- \type -> \context ?
	- \translator -> ?
	- fix \partial 
	- \bla {} vs \bla ; 
	- mix engraver hacking with music ?
	- \once\property  KEY = VAL
	- \addtranslator, \removetranslator
	- junk ^ and _ for scripts
	- junk _ for lyrics.
	- abstract grammar.

	* percussion note heads

	* mi2mu empty staffs.

	* horizontal centering of dynamics 

	* \font\fontA=feta20.afm (.afm?)

	* gzip RH manpage

	* stable make/config stuff

	* $DEPENDENCIES_OUTPUT support

	* Xdvi zooming ?! Try to understand GS garbage collection.
		gs: Error: /undefined in draw_beam
		gs: Operand stack:

	* fix vertical alignment and stafflines

	* GrandStaff needs more work -- I want a single word
	`harpsichord' to the left of the grandstaff, not one on each
	stave.  (Organ staff -- with separate pedal -- but common
	properties may be something to think about.  Of course for
	organ you want to be able to give stop indications on the way
	through, so the \property Voice.Instrument would be a stop,
	and \property GrandStaff.instrument would be PipeOrgan...)

	* revise the Score_priority_align_engraver concept.  It sucks. 

	* make new VoiceOne, VoiceTwo, VoiceThree contexts with
ydirection and hshift preset

	* *.yo: fix pod manpage layout legacy

	* text-items clash with stems/beams

	* --include, -I option for ly2dvi (pass on to lily)

	* fix placement of beam-less abbrev

	* \meter 3/4;
	<{\voiceone cis4. cis8 cis4 | cis4 cis cis | r1 }
	 {\voicetwo cis,4 r r | r2. | r1 }> |
	}

	* try to use template<Type> iso MACRO(Type)

	- NEWS: ... Musical_pitch (analogous to Duration and Rhythmic_req)
	  think about, analogous to pitch: 
	   * { a4 a16 } c <-- duration of c?
	   * < a4 b8 > c <-- duration of c?

	* \tempo 4. = 90;

	* fix audio-items (don't use (input) requests, but copy data)

	* make sure all ex's have a mudela-version

	* do rest-collisions for Multi_measure_rests as well.

	* split error/warning in error/warning/non_fatal_error

	* add a Duration_convert member to Duration_iter to set parameters.
	Junk global duration settings. 

 	* minimum length second part broken tie
 
	* en-,discouraged linebreaking: 
	  - handle DISALLOW < penalty > FORCE
	  - discourage breaking of slurs

	* fix variable define/lookup parser global<->paper

	* fix title/instrument placements; see input/test/title.ly

	* <\voiceone c4. \voicetwo c4>

	* add full cello suites to web site (kom op, Maarten!)

	* Rethink Time_description
	  * \cadenza , \meter, \grouping should all be \properties

	* rename
	  - measure -> bar
	  - abbrev -> tremolo
	  - abbreviation-beam -> (measured/unmeasured) tremolo
	  - partial -> anacrouse

	* shared lib

	* robustify Beam (in case of no stems, 32nd notes)

	* decentralised spring factory

	* move paper vars into engraver properties

	* check for groff / troff/ nroff et

	* more intelligent file searching

	* make LilyPond RPM fully relocatable

	* disable spaces in TeX stuff
	
	* handle ^C for tmp/file creation.

	* dots & rest collisions.

	* documentation
	- introduction?
	- info?
	- LaTeX?
	- more manpages?

	* versioning for Feta

	* the warning about the negative slur/tie length appears twice
	which is irritating.

	* The `3' in the meter key is a one or two pixels too thin (at 600dpi)
	in the middle:

	* the bracket is ugly (wings are too parabolic, should be more circular)

	* better hshift (dots, distance, head dependent)

        * clefs (AG): The "8" should appear closer to the actual clef,
          touching it.

	* put errorlevel in Input class

	* junk nesting slurs

	* integrate midi-elts from mi2mu and lily?


3RD PARTY BUGS:
****************
/*
ICE
*/
signature S {
  int foo ();
};

signature V {
  S * s();
};


V*v();
f ()
{
  return v( )->foo ();
}

/*

  egcs-1.1

foo.cc: In function `int f()':
foo.cc:6: label `b' used but not defined
*/
void
f ()
{
  bool b;
  if (b && && b)
	 ;	
}
***************

	* make GCC warn about ctor that leaves member vars  uninitialised.

	* GNU diff 2.7: diff -rN does not see a new directory with empty file

	* glibc 2.0:

	  f = fopen ("/dev/null", "r")
	  assert (feof (f))

3RD PARTY PROJECTS:

	* GNU patch 
	  - 'double-fix' mode: ignore identical fix, rather than suggest 
	    to revert patch direction when (more or less? exactly) the same 
	    thing is fixed

PROJECTS

	* Scripts:
 	- fix position of bar number
	- stack scripts in chords:
	  % fingering:        footing:
	    < a-4 c-2 g-1 >   < c-\ltoe e-\lheel >
	- script-spacing
	- slur parts as a script
	- stack parameterised scripts for fingering and footing:

 	* convert-mudela:
	- automatically add  a \version if not present.
	- better parsing
	- make smarter
	- convert-mudela -e empty.ly

	* emacs mudela-mode
	-  should handle block comments too.
	-  handle lexer modes (\header, \melodic, \lyric) etc.
	-  indentation
	-  notenames?
	-  fontlock: \melodic \melodic

	* use properties for:
	- plet?
	- Staff_sym size
	- default tempo.
	- font size
	- bartypes (get rid of derived Span_bar_engravers)
	- cadenza mode? 

	* page handling:
	- PS output
	- optimal pagebreaking.

	* Unicode support? -> man 7 unicode
	- 16 bit Strings
	- -u switch
	- detect of 16/8 bit files
	- examples to go with it.

	* Spring_spacer:
	- write a faster Spring_spacer (without matrices if possible)
	- relate energybound to linelen unitspace fontsize etc.
	- used fixed point fp?

	* \header
	- output header info to MIDI too.

	* a musical dictionary. See Documentation/vocabulary-*, other
	languages:
	- explanations
	- italian
	- german
	- dutch
	- swedish
	 .. ?

	* chords
	- guitar chords (fret diagrams)
	- other chord name styles (american(?) style)
	- basso continuo
	- MIDI output?

	* Debug logs:
	- derive lily_stream, Dstream, texstream from ostream?
	- indentable stream as baseclass for TeX stream, lily stream, Dstream.
	- use dstream feature in mi2mu
	- integrate IO checking into stream class

	* input converters
	- NIFF?
	- ABC? 
	- SMDL?

	* add to MIDI output:
	- tempo change
	- ornaments (and trills?)
	- repeat/volta
	- slurs
	- accents
	- dynamics
	- account for rhythmic position in measure
	- etc.

	* grace notes
	- make separate class for Grace_*_engravers 
	(which is at Voice_gravs level)
	- make encapsulated spacing problems.

	* accidentals per Voice_group

	* Output class, handles : (smallish)
	- help text /(c) notice?
	- version line
	- warning /errors/progress
	- abort on error/warning; exit status
	- quiet/ignore-version options
	- logfile output

	* elaborate Staff_side baseclass:
	- scripts
	- text
	- slur start/end

	* PS 
	- speed up PS code.
	- PS lines to .eps files
	- write custom prolog

	* Output an output format independent (ofi) typeset file; and 
	  make ofi2 TeX, MusiXTex, Display PostScript, PostScript,
	  Ascii... interpreters. (difficult)

	- NIFF ?
	- Common Music Notation
	- PostScript output (esp. Beams, Slurs, etc)
	- Move all Score_elems, into libmutype.a
	- SGML

	* Documentation
	- Doc (C) stuff of sheet music
	- a better format?  SGML?  TeX?  Info?
	- a better tutorial

	* more spanners (smallish)
	- Glissando
	- trill

	* Rewrite Stem, Beam and Rhythmic_grouping (hairy)
	- [c8. c32 c32]
 	- doc on Rhythmic_grouping
	- general shaving on Beam and Stem
	- use plet grouping
	- separate visual from rhythmic info even more
	- beams over bars

	* lines:
	- Ledger lines, should be separate item: Ledger_lines, Ledger_lines
	- set different line sizes / thicknesses
	- beam stem showthrough, inter beam sizes (french vs german style)

	* Collisions
	- left/right note balls should be handled by Collision:
	< \multi 2; { \stem 1; <b c> } { <f as b> } >

	* Keys:
	- merge key{item} & localkey{item}?
	- spacing, national styles?

	* Support for TAB
	- redo Notehead to allow digits as heads
	- add a \tablature {} lexer mode for easy entering

	* should adjust stemlength for flag number.

	* breaking:
	- caching breakpoints
	- saving them
	- specify number of lines

INPUTLANGUAGE

	* c4 4 4 4 for c4 c4 c4 c4?

	* neatly (and readably) expressing concurrent
	voices

	* <c f a>4 ?

	* Viola mode?

		@c c g e g 
	for
		c g es g, 

		@A c g e g
	for
		cis gis e gis

	* relative mode for pitch entering

	* configure pitch_byte

	* rest name configurable

SMALLISH PROJECTS

	* limit memory usage; the full coriolan takes up too much resources.

	* fix confusing naming in Engraver vs Engraver_group_engraver (context)

	* progress when creating MIDI elts.

	* A range for context errors (eg. mark both { and }. )

	* lyric in staff  (sharpsharp in staff, text below)

	* half sharps/flats

	* write Dynamic_line (to group dynamics horizontally)

	* use Real for all y positions.
	- use translate_axis( .. ,Y_AXIS)  iso separate variables.

	* half-sharps, half-flats

	* adaptive accidental spacing.

	* handle EOF graciously in error messages.

	* declare notenametab?

	* midi esp.: use I32 iso int where 32 bits are needed (or assumed...)

	* stafftypes: voice names/ instrument names.

	* lily \tempo

	* C meter iso 4/4, idem for alla breve, etc.

	* textspanner: center position

        *   % toe to bheel   four to five
	    %   ^_u            4_5  
	    %     -                           
	    %  --|x--         --|x--
	    %  --|---         --|---
	    %  --|---         --|---
          (where "to" is a tiny bow)

	* auxilliary file for caching info.

	* Text_crescendo

	* clean solution for staffsize in items.

	* revise calcideal

IDEAS

	* Output data structures of Mudela in XML/SGML.

	* create libmudela, or liblily_frontend

	* move MIDI stuff (including Quantization) to a ANSI C libmidi library.

	* Spacing_request for manually adjusting spacing

	* caching breakpoints

	* used fixedpoint arithmetic for min. energy.

	* move towards incremental algorithms.

	* far fetched language ideas
	- design meta-language like TeX and Metafont
	- programming/macros input

	* versioning stuff (cvt mudela, mudela, etc.)

	* Klavarskribo?

	* dynamic loading of engravers? 

SMOBS:

****************************************
Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:

> mcmanus@IDT.NET writes:
> > > I want different C++ objects (with scheme embedded) to be linked by
> > > C++ pointers.  I want to access these other objects from the Scheme
> > > code, and I want access to these pointers from C++.
> > 
> > You can do this with a  combination of smob's and primitive functions,
> > though it may not be  be exactly what you wanted.   You would have one
> > smob  for each class in  your application, and then  you would write a
> > primitive function that would return the objects  that are linked to a
> > base object.
> 
> And the smob and the C++ class are interlinked?  Like
> 
> 	class Foo_class {
> 		Foo_smob *smob_ptr_;
> 	}
> 
> 	struct Foo_smob {
> 		Foo_class *class_ptr_
> 	}

Usually you can get away without having this interlinked structure.
One piece of information you need when exporting objects to scheme is
the smob tag for your class.  You might store this value (a long) into
a class static variable, or a file static variable.  I'll use a class
static variable in this example.

I typically use code that works like this (untested code ahead):

class Foo_class {
    static long *Foo_smob_tag;
    SCM obj; // representation as a scheme object, description comes later
}

// call this once on startup
void init_Foo_class {
    static scm_smobfuns type_rec;

    type_rec.mark = foo_mark;
    type_rec.free = foo_free;
    type_rec.print = foo_display;
    type_rec.equalp = 0;
    Foo_class::Foo_smob_tag = new int(scm_new_smob(type_rec));
}

When you want to export an object to scheme, you put a pointer to the
object itself in the cdr of the cell, and the tag in the car of the
cell.  The code looks like this:

// Is this a Foo?
static int
foo_p(SCM obj)
{
    return(SCM_NIMP(obj) && SCM_CAR(obj) == Foo_class::Foo_smob_tag);
}

// given a Scheme representation, return, a C++ representation
static Foo_class *
foo_unbox(SCM obj)
{
    return((Foo_class*)SCM_CDR(obj));
}

// the SCM representation of the object is stored inside itself
// this will become useful when destructor gets called
static SCM
foo_box(Foo_class *foo)
{
    SCM_DEFER_INTS;
    SCM_NEWCELL(foo->obj);
    SCM_SETCAR(foo->obj, Foo_class::Foo_smob_tag);
    SCM_SETCDR(foo->obj, (SCM)foo);
    SCM_ALLOW_INTS;
    return foo->obj;
}

> C++ determines life time, so what is the strategy?

What happens now when the destructor gets called?  Lets set the cdr to
NULL, and then check for that in all of the primitive functions that
use your smob.  We'll call this notion 'live'; a scheme object is
'live' if the C++ representation still exists, it's dead if the C++
object is gone.  You can still have references to dead objects in
scheme code; it's just an error to use them.  This idea is stolen from
Emacs's handling of buffers ('buffer-live-p' and friends).

Add another function, foo_live_p:

static int
foo_live_p(SCM obj)
{
    return(foo_p(obj) && SCM_CDR(obj) != NULL);
}

In you destructor, you need to do:

~Foo_class()
{
    SCM_CDR(this->obj, NULL);
}

When writing new primitives, now just check foo_live_p().

I hope the above helps,

-russ


--
"Even if you are on the right track, you'll get run over 
if you just sit there."  
             --Will Rogers (1879-1935)

***************************

> I am still muddling along with integrating GUILE in LilyPond, and I
> have a question.  I want to replace an existing C++ implementation of
> identifier tables by GUILE's code.  I've managed to replace
> 
> 	Hash_table<String,Identifier*>
> 
> by
> 
> 	Hash_table<SCM, Identifier*>
> 
> and use interning and GUILE symbols for doing the identifier lookup.
> But I'd like to use GUILE's hash tables as well, and that's were my
> question comes in: is there an interface that allows me to iterate
> through the entries of a GUILE hash table?

I use the following, which should definitely be provided somewhere
in guile, but isn't, AFAIK:

(define (hash-table-for-each fn ht)
  (do ((i 0 (+ 1 i)))
      ((= i (vector-length ht)))
    (do ((alist (vector-ref ht i) (cdr alist)))
	((null? alist) #t)
      (fn (car (car alist)) (cdr (car alist))))))

(define (hash-table-map fn ht)
  (do ((i 0 (+ 1 i))
       (ret-ls '()))
      ((= i (vector-length ht)) (reverse ret-ls))
    (do ((alist (vector-ref ht i) (cdr alist)))
	((null? alist) #t)
      (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))

If you want a C version, you can run the above code through hobbit, or
tranlate it to C by hand.

-russ


--
"Whenever you find yourself on the side of the majority, it is time to
pause and reflect."
             -- Mark Twain
***********************