Subject: mailing-list for TeXmacs Users
List archive
From : "Sam Liddicott" <address@hidden>- To: address@hidden
- Subject: Re: [TeXmacs] get-arity Segmentation fault
- Date: Fri, 08 Apr 2011 08:59:24 +0100
- Envelope-to:
- Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAAXNSR0IArs4c6QAAADxQTFRF NTdQY2Z/i286eHFugnNXoJBwm5GCs5VeoqO0ua+fwLCQ4c2q19C81NDF4eLr/unQ/PTf/fXW+/rq /f/7XKo76wAAAAlwSFlzAAALEwAACxMBAJqcGAAAAi9JREFUSMetloGSqyAMRVsFNAQkxP//15cE 62rFdt/MZqbTVu/hBhLEx/qf8fgDIAN455wHyPk7wCIe9nA+fwGSH87hgD8AHPfRpy2GwdMtcBh+ mg4Ech9Ih+RNixJKDLEL0GF8VLkSojePHrDlryNijbFW8zBg8PUKbBOI6D1WCV5Rf2DzxCtgBlMs tRRVW5LyVW3ew1TfAZZ6RcQicpb4yZmaC74DJADK6BdATOrUAbJzsZie+K22ZnEBknNYysvhVH6u 1X8CqAe4DuANoPoOrAbsHXUARJ5knc5z4EyyTnHoAqj7xvkYIdk65AwhyEZKMusOIDV2QQQaCnDQ gBiDR3RdIEb5CBESt2wgQJI0Yx/Agphg1MgNsD+QkszM9wHVPx/PeQOW+fmcR9DF8+4CyCJhCuP8 fDzmBbLqs8JzMODqYNfDvKhoGYM2lDosy5jlRozccRAgrPM8iygQS3Mv87IugUgKlC7NZ6liuy4r uresVq5QuQAr09ZKEga8OkluyKXeQ6Bs3SrtqgC1pWLNqAfwDhBnB+sK8OrVL4D4h1B4zWPWhJhu gPUHKA5EwSMYUMsdQK+UKDhIOTSHeg+8HCoTOGtB/gwcl4mSdGybwXegPWhM/RHYKwchkckhUNMX 6j7ueQNScLbZZOPRxaADyO2UQCJpl7wbnE6gQ+ksWjpngxOwF1tF5ecP3R6KB+AQxPfHLncQ+nKw 06fhu68OTIfJ869eTtg22l+9zfwDK3mKl5BFHMYAAAAASUVORK5CYII=
On 08/04/11 08:47, Sam Liddicott wrote:
Nope... my version will also eval the args...
even this one will eval the args!!! - but is perhaps neater than the map-args version
<assign|tt|<xmacro|x|<quasiquote|<length|<tuple|<unquote*|<quote-arg|x>>>>>>>
or.... maybe I can't really tell... I don't know when a macro gets evaluated I think... I used to think it was as late as possible, maybe it is as soon as possible?
agghg
This test shows that macros are evaluated as late as possible:
<assign|tt|<xmacro|x|<quasi|<length|<tuple|dup|<unquote*|<quote-arg|x>>|<unquote*|<quote-arg|x>>>>>>>
<assign|ix|<macro|<assign|x|<plus|<value|x>|1>>d>>
<assign|x|0>
<tt|<ix|a|b|c>>
<value|x>
clearly <ix|...> is passed un-evaluated to tt, which - despite the quote-arg still manages to evaluate before it can count.
BUT THIS VERSION DOES WORK:
<assign|tt|<xmacro|x|<quasiquote|<get-arity|<quote-arg|x>>>>>
Sam
Sam
On 08/04/11 08:02, Sam Liddicott wrote:
To follow on from yesterdays message:
I can't believe I just got this to work! (I typed it in a text editor and cut-n-paste to texmacs in one go).
<assign|tt|<xmacro|x|<get-arity|<eval-args|x>>>>
I have a use of eval-args that doesn't segfault!
However I think it is not a good way to get the number of arguments passed to a variable macro, if the arguments have a side-effect (like increasing a counter or setting global variables) then eval-args will cause the side effect.
This macro will also give the number of arguments. I hope there is a better way than this though
<assign|ll|<xmacro|x|<length|<map-args|identity|tuple|x>>>>
I tried this, but it also segfaults
<assign|ll|<xmacro|x|<length|x>>>
I also tried something like this but it seg-faults:
<assign|ll|<xmacro|x|<quasi|<length|<tuple|<unquote*|<arg|x>>>>>>>
Sam
On 07/04/11 22:12, Jan Lellmann wrote:
Hello,
the following code reproducibly produces segfaults when I move the cursor to the "x" inside the macro.
This is bad, since it is the only way to get the number of arguments passed to a variable macro.
----
<TeXmacs|1.0.7.3>
<style|generic>
<\body>
<xmacro|x|<get-arity|<eval-args|x>>>
</body>
<\initial>
<\collection>
<associate|language|american>
<associate|page-type|letter>
<associate|preamble|true>
</collection>
</initial>
----
Any ideas why?
Jan
--
[FSF Associate Member #2325] <http://www.fsf.org/register_form?referrer=2325>
<http://www.openrightsgroup.org/>
- [TeXmacs] get-arity Segmentation fault, Jan Lellmann, 04/07/2011
- Re: [TeXmacs] get-arity Segmentation fault, Sam Liddicott, 04/07/2011
- Re: [TeXmacs] get-arity Segmentation fault, Sam Liddicott, 04/08/2011
- Re: [TeXmacs] get-arity Segmentation fault, Sam Liddicott, 04/08/2011
- Re: [TeXmacs] get-arity Segmentation fault, Sam Liddicott, 04/08/2011
- Re: [TeXmacs] get-arity Segmentation fault, Sam Liddicott, 04/08/2011
Archive powered by MHonArc 2.6.19.